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

Does the file upload work for react native apps ? #350

Open
varshith5c opened this issue Jun 20, 2023 · 2 comments
Open

Does the file upload work for react native apps ? #350

varshith5c opened this issue Jun 20, 2023 · 2 comments

Comments

@varshith5c
Copy link

I have setup all the configuration correctly. When I hit the API using web browser I am able to upload the file . ie I am able to get req.files but when I send it from mobile eventhough the header is multipart/form-data I am not able to get any data in req.files. I always get null as a value

@varshith5c varshith5c changed the title Does the file upload works for react native apps ? Does the file upload work for react native apps ? Jun 20, 2023
@RomanBurunkov
Copy link
Collaborator

Hi.

What exact header you had?
Any examples, snippet, configuration details?

@king-d-dev
Copy link

king-d-dev commented Nov 21, 2023

You need to install form-data and then use the code below to add the file to the request payload. Just setting the header wont do anything

const formData = new FormData()
formData.append("file", { uri: file.path, name: file.fileName, type: file.type })

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

3 participants