Watchduck
Watchduck

Reputation: 1156

Can the download attribute of the anchor tag be used, when the download is from a different subdomain?

When users download images from Wikimedia Commons, the browser will usually take the file name from the URL. The exception are SVG files, where the code contains a title (which is often wrong). I would like to know if it is possible to add a download button with the correct name. (See this discussion on Commons.)

The download parameter of the anchor tag seems to be the right tool for this use case:

<a href="https://upload.wikimedia.org/wikipedia/commons/ab/cd/Name.svg" 
   download="Name.svg">
  Download
</a>

The download link would be on a page like this: commons.wikimedia.org/wiki/File:Name.svg
But the actual SVG is on a different subdomain: upload.wikimedia.org/wikipedia/commons/ab/cd/Name.svg

Can this work despite the different origins? The answer to this question mentions adding the other domain to Access-Control-Allow-Origin. Where would that have to be?

Upvotes: 0

Views: 69

Answers (0)

Related Questions