question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uploading blob - data is empty

See original GitHub issue

Hi, I am trying to upload blob (image) along with some params, but no matter what I can’t seem to put the data in the body of the request.

let blob = new Blob(animal.photos, {type: 'image/png'});
      axios.post( API_URL + 'v1/files/upload/' + animal.photos[0].name ,
       {data: blob},
        {
          params: {
            animalId: response.data.id
          }
        })

Here’s screenshot of google developer tools.

screen shot 2016-08-14 at 14 00 44

What I am trying to do is to send the image binary data as the body of the request to the API, not sure where I am going wrong with this.

BTW I get 500 code, because body is empty.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
JeSuiscommented, Jul 17, 2017

@bericoberin headers: { 'content-type': 'multipart/form-data' }

0reactions
ghostcommented, May 20, 2019

The trick is

  • FormData()
  • boundry in header
  const data = new FormData()
  data.append('file', file, file.name)
  
  axios({
    method: 'post',
    url: "http://localhost:4000/upload",
    data: data, 
    headers: {
      'Content-Type': `multipart/form-data; boundary=${data._boundary}`,
    }
  })

Handle Blobs requests with Axios the right way

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uploading blob with FormData, File content is empty
Chrome developer tools doesn't actually show the content of files in form data, check the sever side to see if the file is...
Read more >
Blob UploadFromStream saves empty files - MSDN - Microsoft
I am uploading an image file to dev blob storage, but it saves empty 1k files. var blob = container.GetBlobReference(url); blob.Properties.
Read more >
Blob - Databricks Community
I am trying to upload blob storage on databricks sql warehouse. I followed this document https://docs.databricks.com/data/data-sources/azure/azure-storage.html.
Read more >
How to Prevent Creation of Empty File through Azure Data ...
How to Prevent Creation of Empty File through Azure Data Factory- Azure Data Factory Tutorial 2021, in this video we are going to...
Read more >
Empty BLOB Value - Oracle to SQL Server Migration - SQLines
... you can use 0x constant (empty binary string). Using EMPTY_BLOB() in Oracle Let's create a table with a BLOB column in Oracle...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found