android - How do I upload an image from my application to my nodejs server? -


i trying upload image android client onto node js server. on client side capture image using callbacks gives me byte[], save internal storage before posting path server (is recommended approach?).

  • i have uploaded entire image buffer cannot streams work.

i have byte[] file have saved internally

fileoutputstream fos = openfileoutput(filename, context.mode_private);         fos.write(image);         fos.close(); file file = new file(getfilesdir() + "/" + filename);         path = file.tostring(); 

and using socket.io connection, emit path of file server

socket.emit("upload_image", _id, path); 

on server side listen emit , try save image file database (mongodb) using module gridjs

socket.on('upload_image', function (_id, img) {  var gs = gridjs(db);  var readstream = fs.createreadstream(img).pipe(gs.createwritestream('test-file')); readstream.on('error', function (err) {     console.log("caught: ", err); }); readstream.on('data', function (data) {     console.log(data); }); readstream.on('open', function () { });} 

the server responds emit client, error thrown when trying create read stream

error: enoent, open '/data/data/com.example.myapplication/files/image-2015-05-31_17-04-59.png' 

i not sure if path have correct, or if im using createreadstream incorrectly. feedback appreciated!


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -