c# - AWSSDK S3 for ASP.NET Core -
i have tried upload file amazon s3 using awssdk .net core, got exception below:
the write operation failed, see inner exception.
the connection server terminated abnormally
no matter connect singapore (global) or beijing (cn-north-1), still has problem.
can give me suggestions solve problem?
this version , codes, please!
.net core / 1.1.1
awssdk.s3 / 3.3.5.10
startup.cs
// add framework services. services.addmvc(); services.adddefaultawsoptions(configuration.getawsoptions()); services.addawsservice<iamazons3>(); appsettings.json
"aws_access_key_id": "xxxxxxxxxx", "aws_secret_access_key": "xxxxxxxxxxxxxxxxxxxxxxxx", "aws": { "region": "cn-north-1", "serviceurl": "https://s3.cn-north-1.amazonaws.com.cn" } controller
private readonly iamazons3 _amazons3client; public userscontroller( iamazons3 amazons3client) { _amazons3client = amazons3client; } [httppost] [route("users/picture/upload")] public async task<iactionresult> uploaduserphoto(string userid) { amazon.s3.model.putobjectresponse response = await _amazons3client.putobjectasync( new amazon.s3.model.putobjectrequest() { bucketname = "mybucket", key = filename, inputstream = uploadfiles[0].openreadstream(), cannedacl = s3cannedacl.publicread }); }
Comments
Post a Comment