If I’m making a Chrome Extension, how do I open an image in a new tab, if server forces the “Save as…” dialog? As I can see, it is something about the Content-Disposition header property.
There are dozens of server-side Q/A about how to force browser to open that dialog, but I can’t find nothing, how to fight with that as an end-user, who doesn’t want that dialog window.
If I’m making a Chrome Extension, how do I open an image in a
Share
In the extended BNF notation of [RFC 822], the Content-Disposition
header field is defined as follows:
If ignoring disposition parameters it simply does the following.
"content-disposition","attachment; filename=fname.jpeg"downloads jpeg file when ever it is served.
"content-disposition","inline; filename=fname.jpeg"displays jpeg file rather downloading jpeg file when ever it is served.
This behavior depends on the browser and the file you are trying to serve.
For example, if you have a JPEG file an inline
disposition-typewill open the Image within browser, whereas attachment will force it to download.If you’re using a .ZIP file, browsers won’t be able to display it inline, so for inline and attachment
disposition-type, the file will be downloaded.You have to use
WebRequest API, to modify your headersSample Code
Make sure you declare
in your manifest file
References
EDIT 1
Add your URL for this code and check if it still throws a
save asdialog.