Updated answer:
I recently updated one of my projects that uses the Amazon AWS .NET SDK (to version 1.4.1.0) and in this version there are two improvements that did not exist when I wrote the original answer here.
- You can now set
Timeout
to -1
to have an infinite time limit for the put operation.
- There is now an extra property on
PutObjectRequest
called ReadWriteTimeout
which can be set (in milliseconds) to timeout on the stream read/write level opposed to the entire put operation level.
So my code now looks like this:
var putObjectRequest = new PutObjectRequest {
BucketName = Bucket,
FilePath = sourceFileName,
Key = destinationFileName,
MD5Digest = md5Base64,
GenerateMD5Digest = true,
Timeout = -1,
ReadWriteTimeout = 300000 // 5 minutes in milliseconds
};
Original answer:
I managed to figure out the answer...
Before posting the question I had explored AmazonS3
and AmazonS3Config
but not PutObjectRequest
.
Inside PutObjectRequest
there is a Timeout
property (set in milliseconds). I have successfully used this to upload the larger files (note: setting it to 0 doesn't remove the timeout, you need to specify a positive number of miliseconds... I've gone for 1 hour).
This works fine:
var putObjectRequest = new PutObjectRequest {
BucketName = Bucket,
FilePath = sourceFileName,
Key = destinationFileName,
MD5Digest = md5Base64,
GenerateMD5Digest = true,
Timeout = 3600000
};
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…