Cannot fetch jpeg image multipart/form-data.
Closed this issue · 0 comments
tskorupka commented
I could not fetch attachment with my server. I could make it before I guess. Nothing changed with my server configuration and its code.
react-native@0.57.0
rn-fetch-blob@0.10.15
Error message in my console
RNFetchBlob failed to create request multipart body :Value for data cannot be cast from Double to String
Attempt to invoke virtual method 'int java.io.InputStream.read(byte[], int, int)' on a null object reference
Code sample
async createAttachment(id: string, uri: string): Promise<Response> {
return RNFetchBlob.fetch('POST', url, {
'Authorization': `Bearer ${await AuthStorage.get()}`,
'Content-Type': 'multipart/form-data'
}, [
{name: 'attachment', filename: 'attachment.jpeg', data: RNFetchBlob.wrap(uri)},
{name: 'id', data: id},
{name: 'name', data: 'attachment.jpeg'}
]);
}
URI sample
/data/user/0/com.example.Example/files/8c9ae0d0-1135-11e9-b1a6-27863b2cdd7c_1546725730.jpeg
RNFetchBlob.fs.exists return value
true