react-native-ssl-pinning: Multipart request (FormData) not work in iOS
with 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 😃
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 31 (16 by maintainers)
@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.
still having the same issue
@canhtran10 can you try to use this branch ? https://github.com/MaxToyberman/react-native-ssl-pinning#ISSUE-67
if it works i will release a new version
Have a great day 😃