2017-09-10 75 views
0

我正在使用AWSSDK.S3 version 3.3.10.2,AWSSDK.CORE版本3.3.17.6Amazon S3 TransferUtilityUploadRequest超時不起作用

我試圖超時添加到TransferUtility.Upload功能

我跟着文檔寫在這裏:http://docs.aws.amazon.com/sdk-for-net/v2/developer-guide/retries-timeouts.html

這是我的代碼:

m_AmazonS3Config.Timeout = TimeSpan.FromMilliseconds(1); 
m_AmazonS3Config.ReadWriteTimeout = TimeSpan.FromMilliseconds(1); 
using (IAmazonS3 s3Client = new AmazonS3Client(m_AmazonS3Config)) 
{ 
    var fileTransferUtility = new TransferUtility(s3Client); 
    var fileTransferUtilityRequest = new TransferUtilityUploadRequest 
    { 
     BucketName = bucketName, 
     Key = key, 
     InputStream = fileStream, 
    }; 

    fileTransferUtility.Upload(fileTransferUtilityRequest); 
} 

我試着上傳大文件,超時沒有打,爲什麼呢?

回答

0

AWS v3文檔是here。您正在使用v3,但您正在關注v2文檔。

此外,您已將超時設置爲1毫秒。考慮到大文件,這還不夠。嘗試設置較大的超時。

var client = new AmazonS3Client(
    new AmazonS3Config 
    { 
    Timeout = TimeSpan.FromSeconds(10),   // Default value is 100 seconds 
    ReadWriteTimeout = TimeSpan.FromSeconds(10), // Default value is 300 seconds 
    MaxErrorRetry = 2        // Default value is 4 retries 
    });