Skip to content

How to make expo upload for mobile version ? #27203

Closed Answered by cupid20103
dtoyoda7 asked this question in Archived: Questions
Discussion options

You must be logged in to vote

I've met this problem before like you.
But no worries, that is very easy.

This is official document for file upload in expo.
Expo file upload method

And this is my code snippet using this.

const result = await FileSystem.uploadAsync(
          `${API_URI}` + "/user/save",
          data.avatar,
          {
            httpMethod: "POST",
            headers: {
              Authorization: `Bearer ${token}`,
            },
            fieldName: "avatar",
            parameters: { ...data.form },
            uploadType: FileSystem.FileSystemUploadType.MULTIPART,
          }
        ).then((res) => JSON.parse(res.body));

I hope this code will help you.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dtoyoda7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants