Blob: Additional bytes added to binary data when retrieving from store
See original GitHub issueWhich service(blob, file, queue, table) does this issue concern?
blob
Which version of the SDK was used?
2.10.3
What’s the Node.js/Browser version?
10.6.0
What problem was encountered?
When retrieving binary data (PNG images in this case) the following error is thrown:
Error: An incorrect number of bytes was read from the connection. The connection may have been closed.
at BlobService._validateLengthAndMD5 (./node_modules/azure-storage/lib/services/blob/blobservice.core.js:5422:28)
at processResponseCallback (./node_modules/azure-storage/lib/services/blob/blobservice.core.js:1879:12)
at Request.processResponseCallback [as _callback] (./node_modules/azure-storage/lib/common/services/storageserviceclient.js:329:13)
at Request.self.callback (./node_modules/request/request.js:185:22)
at Request.emit (events.js:182:13)
at Request.<anonymous> (./node_modules/request/request.js:1161:10)
at Request.emit (events.js:182:13)
at IncomingMessage.<anonymous> (./node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:273:13)
at IncomingMessage.emit (events.js:187:15)
Steps to reproduce the issue?
const { promisify } = require('utils');
const { createBlobService } = require('azure-storage');
const blobSvc = createBlobService();
const createBlob = promisify(blobSvc.createBlockBlobFromText.bind(blobSvc));
const getBlob = promisify(blobSvc.getBlobToText.bind(blobSvc));
async function example() {
await createBlob('container', 'test.png', Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), {
contentSettings: {
contentType: 'application/json',
},
});
await getBlob('container', 'test.png'); // this will throw
}
Have you found a mitigation/solution?
Use getBlobToStream
instead. I understand that the blob is not text data, but if we can send and successfully store buffers representing non-text based data, why can we not retrieve it with the corresponding API. The response from the server seems to be corrupted in the server side as the text data gets 2 additional bytes added to it.
My debugging has found that the data response appears to be correct, but it has some additional trailing whitespace, which adds 2 additional bytes causing the length comparison to fail. Is there a better way to get a Buffer
returned?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Working with binary large objects (BLOBs) - C# Corner
This article illustrates how to work with binary large objects (BLOBs), it will show you how to save and retrieve BLOB values in...
Read more >Retrieving Binary Data - ADO.NET - Microsoft Learn
Binary large objects (BLOBs) need different treatment, however, because they can contain gigabytes of data that cannot be contained in a single ...
Read more >Sending and Receiving Binary Data - Web APIs | MDN
This is building a 512-byte array of 8-bit integers and sending it; you can use any binary data you'd like, of course. Submitting...
Read more >Working with Binary Large Objects (BLOBs) Using SQL Server ...
BLOB data is represented as a byte array in .NET. To read BLOB data, you need to use the SqlDataReader class of ADO.NET....
Read more >Python SQLite BLOB to Insert and Retrieve file and images
To Store BLOB data in the SQLite table, we need to create a table that can hold binary data, or you can also...
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 FreeTop 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
Top GitHub Comments
This issue is specifically about getBlobToText, I suggest you open an new issue rather than tag onto a closed one
Hi, @GagandeepBajwa
Welcome reaching us! Would you please let me know how you upload the images?
Thanks, Jiachen