Amazon S3 using Excel VBA

0

How to download/upload files on PRIVATE buckets in Amazon S3 from Excel VBA? or alternatively, what are VBA instructions to create presigned URLs?

asked a year ago494 views
1 Answer
0

hi You can try using the AWS .NET SDK

  1. Install the AWS SDK for .NET
  2. Set up your AWS credentials, including your AWS Access Key and Secret Access Key.
  3. Create an S3 client using the AWS .NET SDK in your VBA code. You will need to provide the client with your AWS credentials and the S3 bucket name.
  4. To upload a file to the S3 bucket, use the PutObject method of the S3 client. You will need to provide the file path, key name (i.e., the name of the file in the bucket), and the bucket name.
  5. To download a file from the S3 bucket, use the GetObject method of the S3 client. You will need to provide the key name and the bucket name.

Sample code to download a file from a private S3 bucket

Sub DownloadFileFromS3()
    Dim s3Client As Object
    Dim response As Object
    Dim keyName As String
    Dim bucketName As String
    Dim localFilePath As String
   
    'Set AWS credentials
    Set s3Client = CreateObject("Amazon.S3.AmazonS3Client")
    s3Client.Initialize("<Your Access Key>", "<Your Secret Key>", "<Region>")
   
    'Set S3 bucket name and key name
    bucketName = "<The bucket name you want to access>"
    keyName = "<Object name>"
   
    'Set local file path to download the file
    localFilePath = "<Local path where the file will be stored>"
   
    'Download the file from S3 bucket
    Set response = s3Client.GetObject(bucketName, keyName)
   
    'Save the downloaded file to local folder
    response.WriteToFile localFilePath
End Sub

Thanks Arun

AWS
Arun
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions