I am using react.js for front-end,I am trying to uplode the Image directly to aws,via geting url from the my server.
const handleSubmit = async (e) => {
e.preventDefault()
// In this get we url from to uplode profile image to s3 bucket ,first get url from server and then use that url to uplode directly to aws
const res = await fetch("/api/website/aws/get-s3-upload-url") ---url from server to uplode to aws
const data_2 = await res.json()
const profile_url = await data_2.uploadUrl
console.log(`This is profile url ${profile_url}`)
// Now use this url to uplode the image to aws
let form_data = new FormData()
form_data.append("profile_image", profile)
const resp = await fetch(profile_url, {
method: "PUT",
headers: {
"Content-type": "multipart/form-data",
},
body: profile,
})
const data_3 = await resp
The response I am getting from aws after uplode is: enter image description here
What I want is key of the object that i can save to my serve,and when require I can fetch the Image. How can I achive this