我想通过PutObjectAsync()
方法加载一个音频文件,但过了一段时间就会抛出这个异常:
ex = {"Your socket connection to the server was not read from or written to within the timeout period."}
对于.txt文件,这种方法运行得很好,但一旦我加载了.txt以外的文件,就会引发异常。
- 我的txt文件大小:2MB(作品(
- 我的mp3文件大小:700Ko(不起作用(
我的代码:
using(var inputStream = new MemoryStream())
{
await request.File.CopyToAsync(inputStream);
var putObjectRequest = new PutObjectRequest(){
BucketName = "<my_bucket_name>",
Key = "<file_key>",
InputStream = inputStream,
};
await s3Client.PutObjectAsync(putObjectRequest);
}
我正在使用:
- .NET 6
- AWSSDK.S3:版本=";3.7.9.42">
有人能帮我吗?
我在尝试通过AWSSDK S3 API连接到OVHCloud时遇到了这个问题。经过大量的尝试和错误,我发现分块是不起作用的,你还需要显式地设置http状态(UseHttp-注意false的意思是https(。
我希望这能为其他人节省我花费的无数小时。
_s3Client = new AmazonS3Client(AccessKey, SecretKey, new AmazonS3Config
{
ServiceURL = ServiceURL,
AuthenticationRegion = Region,
UseHttp = false
});
var putObjectRequest = new PutObjectRequest
{
UseChunkEncoding = false,
BucketName = BucketName,
Key = key,
InputStream = fileStream
};
await _s3Client.PutObjectAsync(putObjectRequest);