1 Answer
- Newest
- Most votes
- Most comments
0
hi You can try using the AWS .NET SDK
- Install the AWS SDK for .NET
- Set up your AWS credentials, including your AWS Access Key and Secret Access Key.
- 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.
- 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.
- 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
answered a year ago
Relevant content
- asked a year ago
- Accepted Answer
- asked 6 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 4 months ago