-
-
Save revskill10/0443e64fe23fd4191f4c02f5b1d03705 to your computer and use it in GitHub Desktop.
Client side Image Upload To Cloudinary React Dropzone
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
// get's called from react dropzone when file is dropped | |
onImageDrop = (files) => { | |
this.handleImageUpload(files[0]); | |
} | |
async handleImageUpload(file) { | |
const data = new FormData(); | |
data.append('file', file); | |
data.append('upload_preset', CLOUDINARY_UPLOAD_PRESET); | |
const upload = await fetch(CLOUDINARY_UPLOAD_URL, { | |
method: 'POST', | |
body: data, | |
}); | |
const image = await upload.json(); | |
// then do something with image | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment