我是 Amazon S3 的新手,在搜索了 Amazon 和许多网站后,我取得了一些进展。
我正在从应用程序创建一个窗口来上传文件。我尝试使用以下代码,但它没有上传文件,我也没有收到任何错误。
如果我评论 .withKey 属性,则文件将上传到存储桶的根目录,但我想上传到文件夹中的特定文件夹。
Try
Dim fileTransferUtility As New TransferUtility(client)
Dim request As TransferUtilityUploadRequest = New TransferUtilityUploadRequest
Dim S3_KEY As String = "MitsTest/CVs" 'I want to upload file to CVs folder
With request
.BucketName = "mybucketname"
.WithKey(S3_KEY)
.WithFilePath("C:\Users\mitesh\Desktop\s3.txt")
.WithTimeout(FIVE_MINUTES)
End With
fileTransferUtility.Upload(request)
Catch ex As Exception
Finally
End Try
我也尝试过使用以下相同的结果,我没有收到任何错误,但文件没有上传。
Dim Filepath = "C:\Users\mitesh\Desktop\s3.txt"
Dim FolderName = "MitsTest/CVs/"
Dim PutRequest As New PutObjectRequest()
Try
With PutRequest
.WithBucketName("mybucketname")
'.WithKey(FolderName + "/" + FilePath)
.WithKey(FolderName)
.WithFilePath(FilePath)
.StorageClass = S3StorageClass.Standard
.ServerSideEncryptionMethod = ServerSideEncryptionMethod.None
'.WithContentBody(String.Empty)
Dim response As S3Response = client.PutObject(PutRequest)
response.Dispose()
End With
Catch ex As Exception
Stop
End Try
如果我取消注释此行 '.WithKey(FolderName + "/" + FilePath) 并从文件夹名称中删除正斜杠(/),然后我得到“我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签约方式。” 错误。
我在这里错过了什么或做错了什么?任何帮助将非常感激。
问候
米特什