You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constfs=require('fs');constaxios=require('axios');constfilePath='<FILE_PATH>';// Replace with file pathconstbucketURL='<BUCKET_URL>';// Replace with bucket urlconstfileName='<FILE_NAME>';// Replace with file nameconsttoken='TOKEN';// Replace with token value// Read file as a streamconststream=fs.createReadStream(filePath);// Create requestleturl=`${bucketURL}/${fileName}`;letheaders={'Content-type': 'application/octet-stream','Content-Length': fs.statSync(filePath).size//THIS IS IMPORTANT,'Authorization': `Bearer ${token}`}constrequestConfig={headers: headers,}axios.put(url,stream,requestConfig).then(response=>{console.log(response.data);}).catch(error=>{console.log(error.response.data);});
Using FormData changes the Content-type to multipart-form and the bucket endpoint does not accept it. It requires application/octet-stream' (binary). Additionally, the Content-Length` must be set.
Hope this can help others.
Thanks.
The text was updated successfully, but these errors were encountered:
The nodejs example at: https://github.com/zenodo/developers.zenodo.org/blob/master/source/includes/overview/_quickstart.md does not work for me.
I manage it to work using the follow code:
Using
FormData
changes theContent-type
tomultipart-form
and the bucket endpoint does not accept it. It requiresapplication/octet-stream' (binary). Additionally, the
Content-Length` must be set.Hope this can help others.
Thanks.
The text was updated successfully, but these errors were encountered: