Pinata-SDK: Invalid request format
Issue
I have an issue with the pinning of file/directory. When I use Postman, everything works fine, but with SDK I always receive an error Invalid request format
Code example:
const readableStreamForFile = fs.createReadStream('./data/1.dat');
pinata.pinFileToIPFS(readableStreamForFile)
.then((result) => {
//handle results here
console.log(result);
}).catch((err) => {
//handle error here
console.log(err);
});
Version
@pinata/sdk@1.1.10
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 46 (8 by maintainers)
Found it !
Basically the Pinata API complains if you don’t provide a filename for the file you want to pin. The hint was to look at the “Pin Manager” where file names are displayed for every upload.
@obo20 I believe the documentation / recipe book should point out this edge case or the API should return a better error message.
@eightyfive Man, I can’t thank you enough ❤️ I approve his solutions works the best
Confirming that the
stream.path
workaround works for me as well:@eightyfive hack worked for me as well. But I would really really prefer uploading Buffer directly.
dude, you just saved my day, appreciate!! @eightyfive
The SDK should really add a function for uploading Buffers. Ran into this same problem.