Upload Image with fetch / PUT doesn't upload image

113 Views Asked by At

I am trying to upload an image to the bunnycdn with fetch / PUT. I am trying to put the image into the body but it doesn't work this way. Is there anything i can change?

  const uploadpicture = async () => {
    console.log("uploadpic")
    //here use then props.route.params.image etc
    let randomid = uuid()
    let bodyy = new FormData()
    bodyy.append("image",props.route.params.image.uri)
    
    const options = {
      method: 'PUT',
      headers: {
        'content-type': 'application/octet-stream',
        AccessKey: '185e0bd5-1e29-492e-811d6cde3520-4ebe-4c15'
      },
      body: bodyy
    };

    fetch(`https://storage.bunnycdn.com/premvanaprogr/${currentUserObject.uid}/${randomid}.jpg`, options)
      .then(response => response.json())
      .then(response => console.log(response))
      .catch(err => console.error(err))
  }
0

There are 0 best solutions below