I have an url of the image(Not from salesforce) which is stored in another system.

Can i download that file by providing link to the URL in my Lightning component ?

I have tried with "**lightning:formattedUrl value="https://www.someimage...." />" but it doesn't support download.

3 Answers 3


As per my understanding, you want to download the image, so salesforce will provide download feature with below link and it is only for the documents saved in Salesforce.

You might need to save the image in documents tab of Salesforce and Id needs to be added in below URL.

I don't think Salesforce will allow you to download the external image. We can view it but download until that content is added in Salesforce seems to be difficult.

In case of lightning:formattedUrl, below link will go in "Value" attribute and you can keep "Label" as any free text.

/servlet/servlet.FileDownload?file={Attachment Id}&operationContext=S1



Use standard html:

<a href="https://www.someimage...." title="my downloadedfile">

  • The above-mentioned code just opens the link in the same tab. Question here is to download the file. Jun 15, 2020 at 13:52

You'll need to do some workarounds:

<a class="downloader" style="visibility: hidden;"></a>

    fetch(url).then((response) => {
       return response.blob();
    }).then(blob => {
        let link = this.template.querySelector('.downloader');
        link.setAttribute("href", URL.createObjectURL(blob));
        link.setAttribute("download", 'fileName');

Also, add the URL host to Remote Site Settings and CSP policies.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .