[SalesForce] Download file(Image/Doc/PDF) in Lightning component

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.

Best Answer

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

Thanks!

Related Topic