node sdk uploadFile with buffer
Hello,
I'm using node SDK to make an uploadFile from a buffer. And its giving me error "Unexpected API Response [400 Bad Request]"
I used the preflightUploadFile and it's not giving any error. the return is the "upload_url"
I can create folders and such, just getting error on this request.
data.file has the base64, filename has the filename "test.jpg', the folderId i'm using 0 for the test
const data = JSON.parse(event.body);
const buffer = new Buffer(data.file, 'base64');
appUserClient.files.preflightUploadFile(folderId, {name: data.filename, size: 2000000})
.then(file => {
console.log(file);
}).catch(err => {
console.log(err);
});
appUserClient.files.uploadFile(folderId, data.filename, buffer)
.then(file => {
console.log(file);
}).catch(err => {
console.log(err);
});
-
Hi ,
Here's a currently functional example of a direct upload (switch to Node in the tab for code sample). Give that a shot and see if it works.
- Jon
Please sign in to leave a comment.
Comments
1 comment