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
I am using this npm package to upload my files to zenodo bucket, I am getting 200 status code response while calling upload API( internally PUT API of zenodo)
This uploadToZenodo() method is working fine but when I click on the uploaded file I am not able to view my download file. Because I think file which we upload via API is not saving the content of file properly.
Here in this upload method I am not sure what should be data type for upload({
deposition, //mydoi id
filename, //new file name
contentType = 'application/octet-stream',
data // don't know what should be the value of this property like a file or base64 or somthing else?
}}
I tried all the formats but it's not uploading file content.
The text was updated successfully, but these errors were encountered:
data can be anything supported by the axios library. A string, an object (which will be sent as JSON), a Buffer, a stream...
So if you're reading a file in Node.js, you can use fs.readFile(filepath) (without base64 encoding), or fs.createReadStream(filepath).
I am using this npm package to upload my files to zenodo bucket, I am getting 200 status code response while calling upload API( internally PUT API of zenodo)
Here is my code of reference
`const fs = require('fs');
const zenedo = require("zenodo");
const api = new zenedo({
token: '',
protocol: 'https',
host: 'sandbox.zenodo.org',
pathPrefix: '/api/'
});
async function uploadToZenodo() {
const fs = require('fs').promises;
const base64String = await fs.readFile('/home/user/Desktop/data/testFile.pdf', {encoding: 'base64'});
//console.log(base64String);
try{
api.files.upload({
bucketId: '',
filename: 'newFileName.pdf',
data: 'data:image/pdf;base64,' + base64String
}).then(function (response) {
console.log("response is coming for upload file :", response.data);
}, (err)=> {
console.log("Error while uploading file :", err.response);
});
} catch (e) {
console.log("Exception while uploading file :", e);
}
}
uploadToZenodo();`
This uploadToZenodo() method is working fine but when I click on the uploaded file I am not able to view my download file. Because I think file which we upload via API is not saving the content of file properly.
Here in this upload method I am not sure what should be data type for upload({
deposition, //mydoi id
filename, //new file name
contentType = 'application/octet-stream',
data // don't know what should be the value of this property like a file or base64 or somthing else?
}}
I tried all the formats but it's not uploading file content.
The text was updated successfully, but these errors were encountered: