Multipart request (FormData) not work in iOS
See original GitHub issuewith Android it’s working perfectly, i don’t understand why it’s not working in iOS (all ios version), don’t have any parameters transfer to the API server:
THE LOG REQUEST IN SERVER:
Files: "" ; group receipents: "" ; User receipients: ""
The CODE:
const localUploadAttachment = async (url, a, message) => {
let formData = new FormData();
let dataObj = {
name: a.name,
type: 'image/jpg',
uri: a.uri
};
formData.append('files', dataObj); // i tested with "file" parametter but its still not work
formData.append('groupRecipients', JSON.stringify(message.GroupRecipients));
formData.append('userRecipients', JSON.stringify(message.UserRecipients));
let response = fetch(url, {
method: "POST" ,
timeoutInterval: 30000,
body: {
formData: formData,
},
sslPinning: {
certs: ["mycert1"]
},
headers: {
'content-type': 'multipart/form-data; charset=UTF-8',
accept: 'application/json, text/plain, /',
}
})
return response;
}
The LOG API REQUEST:
Please take a look and let me know if you have anything solution for that. Thanks 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:31 (16 by maintainers)
Top Results From Across the Web
multipart/form-data not working anymore, missing filename
I have a function to upload an image using multipart/form-data that was working before, today it stopped working for whatever reason.
Read more >POST multipart/form-data with Obje… | Apple Developer Forums
I have used the multipart/form-data POST on iOS & I had written the following code and it is uploading data but not image...
Read more >[Android] FormData fails to send data in multipart/form-data
On Android, the request is made but both image and description are missing from the request. let formData = new FormData(); formData.append(' ...
Read more >How To Upload Data To A Server: Multipart/Form-Data HTTP ...
MultipartFormDataRequest is very similar to a URLRequest in that it is initialised by a URL. The URL endpoint that you will be sending...
Read more >FormData.append() - Web APIs | MDN
The append() method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@canhtran10 @castalonirenz i have just upload some files i know what was the issue :
2)data: response.data is not needed
i will update the docs.
your code should look like this :
Please let me know if it worked for you
Thanks, will try it tomorrow for sure.