You need to sign in to do that
Don't have an account?
JeffreyStevens
How to download attachment in lightning component
I have a lightning component that I'm putting on a Community page, and I want to place a download link on it - to download an attachment.
In Visualforce - I always did...
<apex:image value="/servlet/servlet.FileDownload?file={!attachmentId}" />Download</apex:image>
So, in the markup of the component, I've tried
<a href="{!'/servlet/servlet.FileDownload?file=00P4D000000Oub6'}">Download</a>
But when I do this, and click on the link - it just's takes me to a Site is in Maintenance message.
Has anybody done a download link of an attachment ID in a componet?
Thanks
In Visualforce - I always did...
<apex:image value="/servlet/servlet.FileDownload?file={!attachmentId}" />Download</apex:image>
So, in the markup of the component, I've tried
<a href="{!'/servlet/servlet.FileDownload?file=00P4D000000Oub6'}">Download</a>
But when I do this, and click on the link - it just's takes me to a Site is in Maintenance message.
Has anybody done a download link of an attachment ID in a componet?
Thanks
<a href="{!'/team/servlet/servlet.FileDownload?file=00P4D000000Ovli'}" target="_blank">Download</a>
All Answers
<a href="{!'/team/servlet/servlet.FileDownload?file=00P4D000000Ovli'}" target="_blank">Download</a>
<a href = "BASE_URL/sfc/servlet.shepherd/document/download/File_ID" >Download</a>
Use This like
<a href="{!'/sfc/servlet.shepherd/document/download/'+ v.Id}" target="_blank">DOWNLOAD</a>
We have the download attribute available for anchor tag. We can use that attribute to get the file downloaded directly. Assuming that you have to do it on a list of records received. Below is the answer.
Can we also use this <a href> for using the DistributionPublicUrl from ContentDistribution?
https://developer.salesforce.com/forums/ForumsMain?id=9062I000000g7aZQAQ