When I'm trying to upload a file to Backblaze B2 (storage provider) using Postman, a header and footer is being added to all files and seems to be damaged and can't be opened
----------------------------114434797603440341474406
Content-Disposition: form-data; name="package.json"; filename="package.json"
Content-Type: application/json
file content
----------------------------114434797603440341474406--
That is happening only when I use form-data to upload file, and it's working fine when I use the binary method in Postman
My questions are:
- Is that header being added by Postman or the storage provider?
- Am I doing something wrong when I'm uploading?
- Is it fine to upload file from client as binary by using FileReader.readAsBinaryString() JS method
This is the C-url request I'm sending
curl --location
--request POST 'https://..........t0045' \
--header 'Authorization: 4_002..........' \
--header 'Content-Type: application/json' \
--header 'X-Bz-File-Name: package.json' \
--header 'X-Bz-Content-Sha1: do_not_verify' \
--form 'package.json=@"/path/to/file/package.json"'
Answering your questions in turn:
FileReader.readAsBinaryString()
.The docs for b2_upload_file explain that you must provide the binary file data in the HTTP message body:
The cURL should look like this: