When opening an object URL in Firefox the file's content is correctly displayed (in the PDF viewer), but "Save page as..." cannot download the blob. The download list in Firefox lists the file as "failed". Clicking on "retry" is successful.
The same approach works successfully in Chrome.
There's no backend involved (at this point). The blob is correctly retrieved in the frontend and displayed, but only on retry is able to download.
The object URL hasn't been revoked (and I can still see an entry in the session storage for the blob. That it always seems to work the second time seems to point to a timing problem to me, but I wouldn't know where to see what failed here.
window.open(URL.createObjectURL(blob))
where the blob was created from the backend's content using Angular's HttpClient:
getContentFileById(id: string): Observable<Blob> {
return this.http.get(`${this.documentUrl}/${id}/content`, {
responseType: 'blob'
});
}
This is both with current Firefox (78.0.2) and Firefox Developer Edition (79.0b9) on macOS Catalina (10.15.5).
It occurs with a file that had the original content disposition attachment
or inline
although I suspects that's lost anyways when it's converted to a blob.
UPDATE:
Here's a simplified minimal example, where I see the same behavior. I couldn't figure out how to create a Blob
directly from an ASCII binary representation, so the example uses a base64-based string. The basic idea to open a created object URL remains the same though:
http://jsfiddle.net/4m8onzu6/9/
Unfortunately this example only opens as PDF file in Firefox, while my actual code also works in Chrome...
I noticed that selecting the normal download button (which most users probably use) works. It's only when you try "Save Page As..." that it first fails, but can download the file on clicking "Retry" in the Downloads list...