usingAmazon.S3;
usingAmazon.S3.Model;
namespaceCreatebucket { classProgram { staticvoidMain(string[]args) { varAk=""; varSk=""; varendpoint="http://s3.test.com"; varbucketName="";
AmazonS3ClientserviceClient=newAmazonS3Client(Ak,Sk, newAmazonS3Config{ServiceURL=endpoint});
try { PutObjectResponseresponse; PutObjectRequestputObject=newPutObjectRequest { BucketName=bucketName, Key="objectName",// object name and path FilePath="filepath",// The full path and name to a file to be uploaded ServerSideEncryptionKeyManagementServiceKeyId="39462e0c-a6f5-4303-bf23-dbb0a7314100", ServerSideEncryptionMethod=ServerSideEncryptionMethod.AWSKMS, }; response=serviceClient.PutObjectAsync(putObject).GetAwaiter().GetResult(); Console.WriteLine(response.HttpStatusCode); } catch(AmazonS3Exceptione) { Console.WriteLine(e.Message); } } } } |