Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    • Top 10 PMD Issues Salesforce Developers Should Focus on in Apex
    • How to Use Graph API for Outlook-Salesforce Connection
    • Enhancing Performance with File Compression in Apex
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Tuesday, May 20
    • Home
    • Architecture
    • Salesforce
      • News
      • Apex
      • Integration
      • Books Testimonial
    • Questions
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Integration Posts
    • Downloads
    • About Us
      • Privacy Policy
    SalesforceCodex
    Home»Salesforce»Apex»Download S3 File in Salesforce using AWS Signature Version 4.0

    Download S3 File in Salesforce using AWS Signature Version 4.0

    Dhanik Lal SahniBy Dhanik Lal SahniAugust 5, 2021Updated:March 5, 202410 Comments3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Download S3 Files
    Share
    Facebook Twitter LinkedIn Pinterest Email

    We are required to store a lot of business files in Salesforce Orgs. We can use Salesforce storage for storing these files but it becomes expensive for larger storage. Amazon S3 and Salesforce Integration can dramatically expand our CRM capabilities by delivering a scalable, secure, and efficient external storage option. This post will provide a step-by-step guide to downloading stored files from the S3 Server.

    Check out our other post to upload files to the S3 Server.

    Use Cases for Amazon S3 in Salesforce

    Document and File Storage

    Rather than using Salesforce’s more limited and pricey storage, store huge files and documents in S3. This is perfect for attaching PDFs, photos, movies, and other media items to your Salesforce entries.

    Backup and Archiving

    Use S3 to backup and archive Salesforce data. This provides data durability and accessibility while successfully controlling costs.

    Data Lakes

    For organisations that utilise Salesforce for customer data and big data analytics, S3 Server can be used to consume, store, and analyse massive amounts of structured and unstructured data.

    Steps for downloading S3 files in Salesforce

    1. Create a named credential for AWS
    2. Create an apex class to download file content
    3. Create an LWC component to download on the client side
    4. Call LWC component on record action

    1. Create a named credential for AWS

    Follow the steps in the section Create a named credential for AWS Credential from our other blog Use Named Credential to Upload File in S3.

    2. Create an apex class to download file content

    Once we created a named credential named S3Server from the above steps. Let us create a class that will download file content from AWS S3.

    FileStore is a Salesforce object that holds S3-related information for uploaded files. This object has fields for storing S3 URL, file extension and file name.

    3. Create an LWC component to download on the client side

    Create an LWC component that will get file data from Apex and show that in different browsers for saving/downloading it.

    It will download the file when the Download File action is clicked on the file store record.

    4. Call LWC component on record action

    Once the LWC component is ready, create an action for the LWC component on the file store record object.

    Record Action for Salesforce Record

    Add that action to the page layout. It will add a download file button on the record page.

    Add Record Action on Page Layout

    Related Posts:-

    Use Named Credential to Upload File in S3

    View S3 File in Lightning Web Component

    Authenticating Requests (AWS Signature Version 4)

    Need Help?

    Need some kind of help in implementing this feature, connect on my LinkedIn profile Dhanik Lal Sahni.

    amazon s3 bucket amazon s3 storage AWS aws s3 api aws s3 bucket aws s3 download aws s3 download file aws s3 upload aws upload file to s3 s3 amazon s3 api s3 aws s3 browser s3 bucket S3 Server s3 storage s3 upload file
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleUse Named Credential to Upload File in S3
    Next Article Extract Driver License Detail from Image using Einstein API
    Dhanik Lal Sahni
    • Website
    • Facebook
    • X (Twitter)

    With over 18 years of experience in web-based application development, I specialize in Salesforce technology and its ecosystem. My journey has equipped me with expertise in a diverse range of technologies including .NET, .NET Core, MS Dynamics CRM, Azure, Oracle, and SQL Server. I am dedicated to staying at the forefront of technological advancements and continuously researching new developments in the Salesforce realm. My focus remains on leveraging technology to create innovative solutions that drive business success.

    Related Posts

    By Dhanik Lal Sahni6 Mins Read

    Top 10 Salesforce Flow Features of Salesforce Summer ’25

    May 11, 2025
    By Dhanik Lal Sahni6 Mins Read

    Unlock the Power of Vibe Coding in Salesforce

    April 30, 2025
    By Dhanik Lal Sahni5 Mins Read

    How to Implement Dynamic Queueable Chaining in Salesforce Apex

    April 21, 2025
    View 10 Comments

    10 Comments

    1. Aman Patil on December 18, 2021 11:49 pm

      Hello Dhanik.
      I am able to download the files correctly without any problem.
      But when I download files of bigger size let’s say 200mb.
      Error says
      System.CalloutException: IO Exception: Exceeded
      max size limit of 6000000.
      Please can you help me here how can we download with greater mb size

      Reply
      • Dhanik Lal Sahni on December 29, 2021 10:18 am

        Hello Aman,

        This is the default behavior for Salesforce. You can check this stack exchange post https://salesforce.stackexchange.com/questions/328492/api-file-download-maximum-file-size.

        Thank You,
        Dhanik

        Reply
    2. Rams on September 13, 2022 5:05 pm

      Hi Dhanik, I would like to access all files from a bucket , Is ther eany possiblity to get all the files instead of a perticular file using filename

      Reply
      • Dhanik Lal Sahni on September 14, 2022 7:07 pm

        Hello Rams,

        I think you have to use CLI or PowerShell commands for downloading the complete bucket. You can refer this post https://stackoverflow.com/questions/8659382/downloading-an-entire-s3-bucket.

        Thank You,
        Dhanik

        Reply
    3. Abhiraj P R on April 4, 2023 9:56 pm

      AccessDeniedAccess DeniedRQ3W59SPRG0KBJVPbhrHVHbFMOg0n8mVkT48pq6qeCZWgaqlz3aO/DOnAKl2SRANROsfJ/zRYt9yAPO2P7UiwlsLpOE=

      got this error when i run this apex

      Reply
      • Dhanik Lal Sahni on April 13, 2023 6:39 pm

        Hello Abhiraj,

        Please check the user access which you are using.

        Thank You,
        Dhanik

        Reply
    4. Suresh on June 1, 2023 10:20 pm

      Hi Abhiraj,
      I got below error. Please help me

      NoSuchKeyThe specified key does not exist.Test15RVFH77BBMSRD8MTE7naqX54rdYRbmnHrf0j9ovBWhwhRylXFUVL+rq57CB2GFFdPuLFWzvPEp9oAAjIfDANzaHR9qY=

      Thanks

      Reply
      • Dhanik Lal Sahni on June 8, 2023 8:07 pm

        Hello Suresh,
        Where are you getting this error? Let us connect to discuss this issue.

        Thank You,
        Dhanik

        Reply
    5. Vijaya Kumar Vegi on June 18, 2023 5:46 pm

      hello dhanik
      i am receving the correct response as a blob content , but its not downloading getting network failure error

      Reply
      • Dhanik Lal Sahni on June 28, 2023 10:47 pm

        Hello Vijay,

        Please check link https://stackoverflow.com/questions/73791508/getting-failed-network-error-while-downloading-pdf-file-from-amazon-s3 for this issue.

        Thank You,
        Dhanik

        Reply
    Leave A Reply Cancel Reply

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (110) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) code review tools (3) custom metadata types (5) design principle (9) einstein (3) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (29) Lightning web component (61) lwc (50) named credential (8) news (4) optimize apex (3) optimize apex code (4) Permission set (4) Queueable (9) rest api (23) S3 Server (4) salesforce (140) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (110) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) code review tools (3) custom metadata types (5) design principle (9) einstein (3) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (29) Lightning web component (61) lwc (50) named credential (8) news (4) optimize apex (3) optimize apex code (4) Permission set (4) Queueable (9) rest api (23) S3 Server (4) salesforce (140) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.