We're transferring a Blob
(image) down a websocket and rendering it to a canvas on the other end.
When I use createObjectURL
with the blob, I get this warning:
Resource interpreted as Image but transferred with MIME type text/plain: "blob:https%3A//example.com/demo".
We create the object URL using the following code. The blob is send via a standard websocket with socket.binaryType = "blob";
on the client side:
socket.onmessage = function(e) { var blob = e.data; var url = (window.URL || window.webkitURL).createObjectURL(blob); var image = document.createElement('img'); image.src = url; }
The only way I can think to address this warning is to create a copy of the blob with the following code, but I don't want to introduce the overhead of copying all the data:
var blob = new Blob([e.data], { type: 'image/gif' });
The method gets called dozens of times per second.
Any ideas on how to set the blob content-type without creating a duplicate Blob
object with new Blob
?
Write-Verbose "Getting the container object named $ContainerName." Write-Verbose "Getting the blob object named $BlobName." Write-Verbose "Changing content type of '$BlobName' to '$ContentType'." Write-Host "Successfully changed content type of '$BlobName' to '$ContentType'."
The Blob object represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data. Blobs can represent data that isn't necessarily in a JavaScript-native format.
Blob storage is optimized for storing massive amounts of unstructured data, such as text or binary data. Blob storage is ideal for: Serving images or documents directly to a browser. Storing files for distributed access.
User-defined metadata: User-defined metadata consists of one or more name-value pairs that you specify for a Blob storage resource. You can use metadata to store additional values with the resource. Metadata values are for your own purposes only, and don't affect how the resource behaves.
Let's consider you have Blob instance (blob
). You can use then slice
method on it:
blob = blob.slice(0, blob.size, "image/jpeg")
and that's it.
It just creates a new blob with the same data, but with the new type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With