I planned to use volley library to solve this. there are some org.apache.http
library (which is deprecated i think). but i want to build my app on latest buld.
i am saving images using gridfs, ie;
var form = new formidable.IncomingForm();
form.keepExtensions = true; //keep file extension
form.parse(req, function (err, fields, files) {
var writestream = gfs.createWriteStream({
filename: fields.temp_name,
mode: 'w',
content_type: 'image/png'
});
fs.createReadStream(files.template.path).pipe(writestream);
writestream.on('close', function (file) {
// do something with `file`
console.log(file.filename + ' Written To DB');
if(err){
res.send("error")
}else{
// do whatever you want
console.log("Upload Session name: "+"upload_complete"+req.session.username);
io.emit("upload_complete"+req.session.username, "File Uploaded Successfully");
//io.emit("upload_complete", "File Uploaded Successfully");
}
});
}else{
io.emit("upload_error"+req.session.username, "Duplicate Name");
}
on webside (browser-server) i first save image to temp directory on server then i write into mongodb using gridfs. (i dont know if this is the correct way!)
how to upload images from android? volley
is better ? or which is the best way to do this?
can you provide a good guide to do this? or please share some code..