如何从AWS S3上传器获得响应

时间:2017-11-20 10:48:54

标签: jquery asp.net-mvc amazon-web-services model-view-controller amazon-s3

我正在使用AWS S3来存储文件。 我能够上传和删除文件。 唯一的问题是上传大文件时,如何知道上传了多少,我需要实现进度条。

请帮我做。

 IAmazonS3 client = new AmazonS3Client(RegionEndpoint.USEast2);
            TransferUtility utility = new TransferUtility(client);
            TransferUtilityUploadRequest request = new TransferUtilityUploadRequest();
if (subDirectoryInBucket == "" || subDirectoryInBucket == null)
            {
                request.BucketName = bucketName; //no subdirectory just bucket name  
            }
            else
            {   // subdirectory and bucket name  
                request.BucketName = bucketName + @"/" + subDirectoryInBucket;
            }
            request.Key = RandomString()+ Path.GetExtension(e.File.FileName); //file name up in S3  
            request.InputStream = e.File.InputStream;
            request.CannedACL=S3CannedACL.PublicRead;
            utility.Upload(request); //commensing the transfer 

我正在使用此代码。

1 个答案:

答案 0 :(得分:0)

您可以使用方法调用TransferUtilityUploadRequest,

下面是

示例,您也可以参考此link!希望这有帮助

public string CheckInAndOut { get { return CheckIn + " " + CheckOut; } }