Sending a image to backend server
See original GitHub issueHey there. I am trying to send a image which i get from the response and send it via fetch to my server.
UIImagePickerManager.showImagePicker(options, (didCancel, response) => {
console.log('Response = ', response);
if (didCancel) {
console.log('User cancelled image picker');
}
else {
var fileName = response.uri.substring(response.uri.lastIndexOf("/") + 1);
var fsPath = response.uri;
var binaryResponse = response.data;
fetch('http://XXXX/user/avatar', {
method: 'POST', // default 'POST',support 'POST' and 'PUT'
headers: {
'Authorization': AuthStore.getUserTokenWithBearer()
},
body: JSON.stringify({image: fsPath})
}).then(function (response) {
console.log(response)
}).catch(function(error){
console.log(error);
});
}
I know this isn´t a modules issue, but trying to find solution from stackoverflow or any other sources failed. Maybe someone has tried this with this component and success?
Issue Analytics
- State:
- Created 8 years ago
- Comments:22 (5 by maintainers)
Top Results From Across the Web
The Better Way of Sending Data to the Backend
At first, you have to create an instance of the formdata. var formData = new FormData(); and then you have to append the...
Read more >Send an image to your backend with the fetch() function
Send an image to your backend with the fetch() function — JavaScript, React ; File or ; Blob objects to specify the file...
Read more >how to upload image from frontend to backend - Stack Overflow
On click that button,a modal is opening. There is two different field called Image Title, Input File. On submit the Save button. It...
Read more >Sending image files from back-end to front-end - JavaScript
I'm having difficulty figuring out how to send an image file from my express back-end to my front-end react application. It's a chat...
Read more >how to send images quickly from a backend to a frontend
You can use FormData () constructor to send binary data directly to the backend. At first, you have to create an instance of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ShanthiSenguttuvan grab the url from image picker, then try this:
Update: this is client code for uploading image to your server. If your question is about how to get image content on server side, then you can refer to nodejs documentation.
Hello ! I don’t really understand what is your problem but i can give you an example, in the folowing example i post an image to cloudinary using fetch, fileUpload is still a good solution !