我正在尝试将图片上传到我们的S3服务,但除了 无缝执行以下代码,我无法访问我上传的文件,文件本身也不在桶上。
另一个包括问题的问题是,除了已经完成的百分比之外,我没有任何实际进展响应。
private AmazonUploader()
{
_access = MyKey###";
_secret = "MySecret###";
AmazonS3Config config = new AmazonS3Config ();
config.ServiceURL = "s3-eu-west-1.amazonaws.com";
config.UseHttp = true;
config.RegionEndpoint = Amazon.RegionEndpoint.EUWest1;
_client = new AmazonS3Client (_access, _secret, config);
_trans = new TransferUtility (_client);
}
public async void UploadImage(string path, string key)
{
TransferUtilityUploadRequest up = new TransferUtilityUploadRequest();
up.BucketName = "myapp/uploads";
up.FilePath = path;
up.Key = key;
up.UploadProgressEvent += up_UploadProgressEvent;
await _trans.UploadAsync(up);
}
private void up_UploadProgressEvent(object sender, UploadProgressArgs e)
{
if (e.PercentDone == 100)
{
System.Diagnostics.Debug.WriteLine ("Done uploading");
if (OnUploadComplete != null) OnUploadComplete ();
}
}
答案 0 :(得分:0)
您的BucketName似乎无效。存储桶名称不能包含斜杠。也许你想要"上传#34;成为Key的一部分?