File is not uploading via ZenodoApi --> ZenodoApiFiles --> upload() method
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the ZenodoApiFiles.upload() method and compare its handling of the provided base64 PDF data with the uploadToZenodo example. Confirm the expected data value and content type, then verify that an uploaded PDF can be viewed or downloaded with its contents intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100