I have an application in node js in which I am uploading the image to the node server after that I compress the file to reduce the size. After that, I upload it to dropbox but the uploaded file has a 0-byte size. I don't understand the problem. Below is the code that I used.
var dir ="C:\\Users\\uploads\\converted\\"+foldername;
fs.readdir("C:\\Users\\uploads\\converted\\"+foldername, function (err, files) {
//handling error
if (err) {
return console.log('Unable to scan directory: ' + err);
}
else {
//listing all files using forEach
files.forEach(function (file) {
console.log(file);
var dbx = new Dropbox({ accessToken: 'xxxx' });
dbx.filesUpload({path: '/'+link+'/'+file , contents: file.data})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.error(error);
});
});
}
});