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 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) |
@sunnynegi maybe because of the url your are sending too, localhost:port is an invalid request because you do not let them to use the default port but you do not define any port yourself
@koswarabilly Well thanks for suggestion, Problem is solved i am using fecth blob for uploading images.
@sunnynegi Can u please post your code sample for uploading?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need help over how to upload image in react native here is my code
onFormSubmit = (e) => {
Issue i am facing is {"statusCode":400,"error":"Bad Request","message":"Invalid content-type header: multipart missing boundary"}