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?

已提问 1 年前578 查看次数
1 回答
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
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则