Upload blob runtime error
See original GitHub issue- Package Name: @azure/storage-blob
- Package Version: ^12.10.0
- Operating system: Ubuntu 20.04.4 LTS
- nodejs
- version: v14.18.2
- browser
- name/version:
- typescript
- version:
- Is the bug related to documentation in
- README.md
- source code documentation
- SDK API docs on https://docs.microsoft.com
Describe the bug
Got error Error: body must be a string, Blob, ArrayBuffer, ArrayBufferView, or a function returning NodeJS.ReadableStream
.
Although console.log(`blob instanceof Blob: ${blob instanceof Blob}`);
outputs blob instanceof Blob: true
, and console.log(blob);
output Blob { size: 22, type: 'application/json' }
To Reproduce
Run following code using node index.js
.
index.js:
const connStr = ".....";
const { BlobServiceClient } = require("@azure/storage-blob");
const { performance } = require('perf_hooks');
const { Blob } = require('buffer');
const blobServiceClient = BlobServiceClient.fromConnectionString(connStr);
const containerName = "newcontainer1653680240090";
async function main() {
const start = performance.now();
const containerClient = blobServiceClient.getContainerClient(containerName);
const obj = { hello: 'world' };
const blob = new Blob([JSON.stringify(obj, null, 2)], { type: 'application/json' });
console.log(`blob instanceof Blob: ${blob instanceof Blob}`);
console.log(blob);
const blobName = "newblob" + new Date().getTime();
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
await blockBlobClient.upload(blob, blob.size);
console.log(performance.now() - start);
}
main();
Sample package.json:
{
"name": "AzureBlobTest",
"version": "1.0.0",
"description": "performance test",
"main": "index.js",
"author": "Xin Zhang",
"license": "MIT",
"dependencies": {
"@azure/storage-blob": "^12.10.0"
}
}
Expected behavior The blob should be uploaded without error
Screenshots
Additional context N/A
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Azure blob storage upload fail - Microsoft Q&A
Uploading files to blob endpoint Azure storage account via Storage Explorer and command line is failing with error "Response Status: 403 ...
Read more >Failed to upload file Standard_Error_Output.log to Blob ...
Getting the below given error on the release Pipeline, in the Visual Studio Test Task, This is executing on a self hosted agent...
Read more >Unable to upload/download blob storage to container from ...
However, when I run the same thing from visual studio (local) I get error at uploading file to blob storage. Microsoft.Azure.Storage.
Read more >Azure Blob Upload Task error – SQLServerCentral Forums
Azure Blob Upload Task error ... Hi,. I am trying to understand an SSIS package where a previous employee who left has written...
Read more >REIM_FIXED_DEAL_UPLOAD_J...
REIM_FIXED_DEAL_UPLOAD_JOB is failing with below error: Runtime : Fixed Deals Upload work 100 failed with error: Cannot build a blob from a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@xirzec Thanks for replying. I was trying to get some performance analysis for request body using different types between
string
,stream
,ArrayBuffer
,blob
and noticed this.If I read the code correctly, eventually everything was serialized to
string
so using a string body is most efficient, especially the item I want to save is already a string?Since the check given is
typeof Blob === "function" || typeof Blob === "object") && value instanceof Blob)
perhaps you could cheese the logic by making the constructor global? Something likeglobal.Blob = Blob
?