Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload image not working on 3.0.1 #317

Open
AbhijitKurane opened this issue Aug 15, 2023 · 3 comments
Open

Upload image not working on 3.0.1 #317

AbhijitKurane opened this issue Aug 15, 2023 · 3 comments

Comments

@AbhijitKurane
Copy link

AbhijitKurane commented Aug 15, 2023

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.

@wesleyvandevoorde
Copy link

I have the same issue

@pnthach95
Copy link

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

@hassan-viabletree
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants