Giter VIP home page Giter VIP logo

Comments (5)

nkzawa avatar nkzawa commented on August 20, 2024

Could you give me your code?

from socket.io-stream.

maeuca avatar maeuca commented on August 20, 2024

There are 2 files attached to this message.

  1. upload.html
  2. ioserver.js

[ upload.html ]

START

 <script type="text/javascript" 

src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/js/socket.io-stream.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
$(function() {
$('#file').change(function(e) {
var file = e.target.files[0];
var stream = ss.createStream();

             // upload a file to the server.
             ss(socket).emit('file', stream, {size: file.size});
             ss.createBlobReadStream(file).pipe(stream);
         });
     });

     var socket = io.connect('http://localhost:8080');

     socket.on('connect', function(){
         console.log('socket ready!');
     });

 </script>

END

[ ioserver.js ]

START
var fs = require('fs');
var path = require('path');
var ss = require('socket.io-stream');

var startIOListener = function() {
var app = require('http').createServer(function (req, res) {
fs.readFile(__dirname + '/public/upload.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
})
, io = require('socket.io').listen(app)
, fs = require('fs')
app.listen(8080);

 io.sockets.on('connection', function (socket) {

     ss(socket).on('profile-image', function(stream, data) {
         var filename = path.basename(data.name);
         stream.pipe(fs.createWriteStream(filename));
     });

 });

}

startIOListener();
END
The error seems to be in upload.html, but I'm kinda stuck on why.

Thanks in advance.
Mark

------ Original Message ------
From: "nkzawa" [email protected]
To: "nkzawa/socket.io-stream" [email protected]
Cc: "maeuca" [email protected]
Sent: 10/8/2013 12:25:49 PM
Subject: Re: [socket.io-stream] Browser socket.io-stream (#14)

Could you give me your code?


Reply to this email directly or view it on GitHub.

from socket.io-stream.

nkzawa avatar nkzawa commented on August 20, 2024

Sorry for the late reply.

Did you expose the file to a public directory like the following?

$ cp node_modules/socket.io-stream/socket.io-stream.js somewhere/public/

See: https://github.com/nkzawa/socket.io-stream#browser

from socket.io-stream.

maeuca avatar maeuca commented on August 20, 2024

my web server was not configured properly.

working fine now, thanks!

--- Original Message ---

From: "nkzawa" [email protected]
Sent: October 10, 2013 11:58 AM
To: "nkzawa/socket.io-stream" [email protected]
Cc: "maeuca" [email protected]
Subject: Re: [socket.io-stream] Browser socket.io-stream (#14)

Sorry for the late reply.

Did you expose the file to a public directory like the following?

$ cp node_modules/socket.io-stream/socket.io-stream.js somewhere/public/

See: https://github.com/nkzawa/socket.io-stream#browser


Reply to this email directly or view it on GitHub:
#14 (comment)

from socket.io-stream.

mukeshkanyal avatar mukeshkanyal commented on August 20, 2024

it showing browserify:command not found when i'm run this command in terminal browserify index.js -s ss > socket.io-stream.js

from socket.io-stream.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.