将文件上载到Amazon S3会引发异常

时间:2013-04-21 10:19:39

标签: asp.net-mvc amazon-web-services amazon-s3 stream

我正在使用亚马逊.net sdk将文件作为流上传到S3,我已经“无法关闭流,直到写完所有字节。”上传时例外。 我的代码:

public void Upload(Stream fileStream, string path)
    {
            TransferUtility transferUtility = new TransferUtility(Client);
            transferUtility.S3Client.PutBucket(new PutBucketRequest() { UseClientRegion = true }.WithBucketName("bucket"));
            TransferUtilityUploadRequest request = new TransferUtilityUploadRequest()
            .WithBucketName("bucket")
            .WithKey("key")
            .WithTimeout(100 * 60 * 60 * 1000)
            .WithPartSize(10 * 1024 * 1024)
            .WithAutoCloseStream(true)
            .WithCannedACL(S3CannedACL.PublicReadWrite)
            .WithInputStream(fileStream) as TransferUtilityUploadRequest;

            transferUtility.Upload(request);
    }

注意:我尝试使用基本配置,这只是BucketName&键和添加的超时,partize ..etc但没有任何改变。

0 个答案:

没有答案