Reputation: 759
I'm trying to post a blob. It's definitely a blob. This isn't working in react-native though. I'm getting a red screen that says "PUT must have a request body". Well, I've put the blob in the request body.
createAttachment: function(url, blob) {
var settings = {
method: "PUT",
headers: {
'Accept': 'image/jpeg',
'Content-Type': 'image/jpeg',
'If-Match': '*',
},
body: blob
};
return fetch(url, settings)
}
Upvotes: 6
Views: 13172
Reputation: 1261
Use rn-fetch-blob
lib for this:
https://github.com/joltup/rn-fetch-blob#user-content-upload-example--dropbox-files-upload-api
Upvotes: 0
Reputation: 873
My project had same problem before, according to this issue perhaps, blob data is not supported in react native fetch
API currently (Both in send and receive).
So I made a module myself ..
https://github.com/wkh237/react-native-fetch-blob
It works fine in our project, if you don't mind to take a look, it might helps.
Upvotes: 11