apisauce icon indicating copy to clipboard operation
apisauce copied to clipboard

Upload image not working on 3.0.1

Open AbhijitKurane opened this issue 2 years ago • 3 comments

Below is the code,


        const form = new FormData()

        form.append('image', {
          name: imageFileName,
          type: imageType,// image/jpeg
          uri: Platform.OS === 'ios' ? imageFilePath.replace('file://', '') : imageFilePath,
        })

        const result = await userInfo.updateUserImage(form)

This fails to work on version 3.0.1 with http error code 400 bad request but the same works on version 2.1.6. I did checked for logs in addAsyncRequestTransform method. For both version 2.1.6 as well as 3.0.1 the request json formed is same but the image gets uploaded successfully on version 2.1.6 and fails on 3.0.1 with http error code 400 bad request.

AbhijitKurane avatar Aug 15 '23 11:08 AbhijitKurane

I have the same issue

wesleyvandevoorde avatar Nov 24 '23 10:11 wesleyvandevoorde

Have you tried adding 'Content-Type': 'multipart/form-data' to header? It has 'Content-Type': 'application/json' by default even if you use FormData

pnthach95 avatar Nov 29 '23 09:11 pnthach95

Have you tried adding 'Content-Type': 'multipart/form-data' to header? It has 'Content-Type': 'application/json' by default even if you use FormData

This worked.

hassan-viabletree avatar Feb 27 '24 14:02 hassan-viabletree