function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
asadimasadim 

Actual link to an Attachment file

Hi,

 

Anybody knows how to get the actual link to a file sitting inside an Attachment? Currently when you say "View this file" you go to something like:

https://na2.salesforce.com/servlet/servlet.FileDownload?file=00PA0000005EPlt

 

What I'm looking for is:

http://??????????/myFile.doc

 

Any ideas? Thanks!

Pradeep_NavatarPradeep_Navatar

In my opinion it’s not possible to get actual link(as you want) to a file, since salesforce provide an unique id for every entity you save to salesforce.And this id is used for accessing these entities.

Ken KoellnerKen Koellner
It seems to me you should at least be able to create a download link if you have the ID of the attachment.  Your controller can query and get the ID.

The trick is figuring out how to generate the begining of the URL for your instance.

In the example above, getting 00PA0000005EPlt in your controller is easy.

What may be harder is figuring out the beginning -- https://na2.salesforce.com/servlet/servlet.FileDownload

This thread is old.  The attachments now come off a server like -- https://c.na15.content.force.com/servlet/ -- so it would be harder to generate that from the based SF URL.