jonsnow19 avatar image
jonsnow19 asked

Upload Image inside a specfic folder.

I am trying to upload an image from local to amazon cloud drive. I am not getting any error with below code but still not able to see the file when I log into portal. I am able to upload the folder easily. Any help ? function uploadFile(token, filePath, title, parentNodeId, cb) { var url = amazonEndpoint.contentUrl; url += 'nodes?suppress=deduplication'; // REMOVE SUPPRESS WHEN ADDING HANDLING FOR DUPES! var parents = []; if (parentNodeId) parents.push(parentNodeId); var form = new FormData(); form.append("metadata", JSON.stringify({ "name": title, "kind": "FILE", "Content-Type": "image/jpeg", "parents": parents})); form.append("content", fs.createReadStream(filePath)); form.getLength(function(err, length) { if (err) { return cb(err); } var r =, function(err, response, body) { if (err) { cb(err); } else { cb(null); } }); r._form = form; r.setHeader("content-length", length); r.setHeader("Authorization", "Bearer " + token.access_token); r.setHeader("Content-Type", "multipart/form-data"); r.setHeader("User-Agent", "testing") }); }
amazon drive
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers