Created
October 3, 2016 15:18
-
-
Save EQuimper/464e09e9101b6977e9c4e25470d6679d to your computer and use it in GitHub Desktop.
Upload React-Native photo to server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const photo = { | |
| uri: image, | |
| type: 'image/jpeg', | |
| name: 'avatar.jpg', | |
| }; | |
| /* globals FormData */ | |
| const data = new FormData(); | |
| data.append('avatar', photo); | |
| const options = { | |
| body: data, | |
| headers: { | |
| ...api.headers, | |
| 'Content-Type': 'multipart/form-data' | |
| }, | |
| method: 'POST', | |
| }; | |
| const res = await fetch('/upload', options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sunnynegi Can u please post your code sample for uploading?