Azure blob storage

Hello, I'm using T3 stack and want to send image (Buffer) to azure blob storage in back-end (await blockBlobClient.upload(...)). However, I get error: "Code": "MissingRequiredHeader", "Message": "An HTTP header that's mandatory for this request is not specified.\nRequestId:...", "HeaderName": "x-ms-blob-type" Does anyone know why? I tried to add header to response, but it didn't help. blockBlobClient.upload(...) should add header by default. On a simple node program it uploads with no error, so the code must be fine
Solution:
Update - managed to fix it. I had error before my file was in storage, thus blobHTTPHeaders was needed after the fix. I use yarn as package manager and with it installed Azure blob storage. Turns out, problem was with packages (modules). I don't know if it didn't install all packages, they were old version or something else, but I had to: 1) Delete node_modules folder 2) Delete yarn.lock file 3) Run all packages install again (few times)...
Jump to solution
5 Replies
Kar olis
Kar olisOP6mo ago
I'm still looking for help, but as workaround - sending requests not from library, but in Axios worked. However, not all auth are "supported"
zezima
zezima6mo ago
Azure is unable to infer the mime type from the file itself, so you have to provide it. I use bun to read the file and grab the type from there:
No description
Kar olis
Kar olisOP6mo ago
I tried that before, but it didn't help. Also, on standalone node app, code worked fine (no MIME errors), so error should be in framework, version or something else. I use blockBlobClient.upload(...), which I believe has x-ms-blob-type defined in library
zezima
zezima6mo ago
That’s interesting, have you tried explicitly passing the header through into the options? With .upload it’s the third parameter after the content length, even though you say it should be getting set itself, curious to see if setting it there makes it work
Solution
Kar olis
Kar olis6mo ago
Update - managed to fix it. I had error before my file was in storage, thus blobHTTPHeaders was needed after the fix. I use yarn as package manager and with it installed Azure blob storage. Turns out, problem was with packages (modules). I don't know if it didn't install all packages, they were old version or something else, but I had to: 1) Delete node_modules folder 2) Delete yarn.lock file 3) Run all packages install again (few times) Thanks for the help and I hope this helps someone 🙂
Want results from more Discord servers?
Add your server