REST Service to Expose Attachments as Public CURL
My use case behind this blog post is to expose Salesforce Attachment (Image/Pdf/Video) as a public accessible CURL, without having to authenticate to Salesforce. And we are going to use REST Web-services and Public Sites to do this! Step 1: Create an Apex REST class with below code snippet. /* * Purpose : Apex rest webservice to return attachment body for a given id * * Developer: SFDC_Dev * */ @RestResource (urlMapping = '/Document_V1/*' ) global class DocumentV1 { @HttpGet global static void docBody() { RestRequest request = RestContext . request; RestResponse res = RestContext . response; try { // Retrieve attachment id from the request url String docId = request . requestURI . substring(request . requestURI . lastIndexOf( '/' ) + 1 ); // Query attachment sObject to get the specific attachment using attachment id ...