Error "Unexpected end of multipart data" in busboy file upload
For me, I received this error when I used \n
newlines instead of \r\n
newlines when formatting my post body on the client side.
When I fixed the newlines (as seen in code below) it worked.
fetch('/api/upload', { method: 'POST', credentials: 'include', headers: {'Content-type': 'multipart/form-data; boundary=XXX' }, body: '--XXX\r\nContent-Disposition: form-data; name="file"; filename="filename.csv"\r\nContent-Type: text/csv\r\n\r\nA,B,C\r\n1,1.1,name1\r\n2,2.2,name2\r\n\r\n--XXX--' });
This is a bug related to firebase tools. I came across this issue with busboy package today and it cost me 2hrs to fix this issue. We just need to upgrade the firebase tools to fix this issue.
Case 1: If you've installed firebase tools as your package dependency, run below code
npm i firebase-tools
Case 2: If you've installed firebase tools as global dependency,run below code
npm i -g firebase-tools
Working Version of firebase tools:
I Hope this helps, for more info checkout this issue link.
If anybody else is having an issue with this still, my issue was something on the front end. Using Swift, it seems like there was an issue if you use the default URLSession config. I changed it from:
let session = URLSession(configuration: .default, delegate: self, delegateQueue: nil)
to the following:
let sessionConfig = URLSessionConfiguration.background(withIdentifier: "it.yourapp.upload") sessionConfig.isDiscretionary = false sessionConfig.networkServiceType = .default let session = URLSession(configuration: sessionConfig, delegate: self, delegateQueue: OperationQueue.main)
and now it works great!