Cannot load BLOB into img tag when using query params

NEW
Unassigned

Status

()

Firefox
General
5 years ago
5 years ago

People

(Reporter: pdehaan, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 years ago
Another bug from a friend:
---

I am creating an URL from blob, which works as expected. When I want to use that URL, it also works, as such:

```
var blob = new Blob([SomeArrayBuffer], awesomeImageMimeType);

var myCoolImage = document.createElement(img);

document.appendChild(img);

var imgUrl = window.URL.createObjectURL(blob);

myCoolImage.src = imgUrl;
```

Great, this works, the internet wins!

The issue is this, let's say I'm hacking away, and want to do something create like add a query string to that URL from the blob.

```
myCoolImage.src = imgUrl + '?somedata=1234';
```

Don't ask me why I want to do this, but, I need to do this, and the browser should handle this. I would expect the browser to be smart enough to either omit the query string when resolving a blob URL or simply strip it out if it doesn't work, but honestly, it should just resolve the request and omit the query string if it doesn't want to do anything with it but leave it for me use.
(Reporter)

Comment 1

5 years ago
Sorry, I made a slight typo in the pseudo-pseudo-code (and cant see a way to edit existing comments/description). The actual working code should be:


```
var blob = new Blob([SomeArrayBuffer], awesomeImageMimeType);

var myCoolImage = document.createElement('img');

document.appendChild(myCoolImage);

var imgUrl = window.URL.createObjectURL(blob);

myCoolImage.src = imgUrl;
```
Just a note, this is on any type of blob and element set upon, not just images. Using images purely to illustrate the problem.
Ping, anyone looking at this?
You need to log in before you can comment on or make changes to this bug.