-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Spaces in filename (multipart) #248
Comments
@St1ma , I've made a simple test case for this issue but unfortunately the problem could not be replicated. Perhaps the spaces in filename is not the root cause. Is it possible to provide a sample file and code snippet ? |
@wkh237 It was download form iCloud Drive with parameters:
Post file (as multipart) function stuck by executing Blob.build Promise
Thank you for your quick response. |
@St1ma , if you intend to embed the file into multipart form, there is no need to create a blob, you can directly pass async postFile(url, { fileUri, fileType, filename }) {
try {
- const Blob = RNFetchBlob.polyfill.Blob;
- const blobUri = RNFetchBlob.wrap(Platform.OS === 'ios' ? fileUri.replace('file://', '') : fileUri);
- await Blob.build(blobUri, { type : fileType });
const res = await RNFetchBlob.fetch('POST', `${this.prefix}/${url}`, {
'Content-Type' : 'multipart/form-data'
}, [
+ { name : 'file', filename, type: fileType, data: RNFetchBlob .wrap(fileUri) }
]);
const data = await res.json();
if (data && data.status === 1) {
return data;
}
if (this.onError) {
this.onError(data.error);
}
return Promise.reject(data.error);
} catch (e) {
return Promise.reject(e);
}
} |
@wkh237 |
I'm having the same issue with an imported file from iCloud. |
I managed to find the root cause. The path was passed to the uploader in URI encoded style. So it was like "my%20file.pdf" instead of "my file.pdf" {
name: 'file',
filename: 'original.pdf',
type: 'application/pdf',
data: "RNFetchBlob-" + decodeURI(filePath)
} |
Hello!
I'm trying to make blob from file with spaces in name - "Venetoclax GVD tracked changes Sep 13.docx"
The process stop at Blob.build method
Url value (for emulator):
P.S. Thanks for library!
The text was updated successfully, but these errors were encountered: