当前位置: 首页>>代码示例>>C#>>正文


C# AmazonS3Client.PutObjectAsync方法代码示例

本文整理汇总了C#中Amazon.S3.AmazonS3Client.PutObjectAsync方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonS3Client.PutObjectAsync方法的具体用法?C# AmazonS3Client.PutObjectAsync怎么用?C# AmazonS3Client.PutObjectAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Amazon.S3.AmazonS3Client的用法示例。


在下文中一共展示了AmazonS3Client.PutObjectAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UploadDataFileAsync

        public async Task UploadDataFileAsync(string data, string storageKeyId, string storageSecret, string region)
        {
            var regionIdentifier = RegionEndpoint.GetBySystemName(region);
            using (var client = new AmazonS3Client(storageKeyId, storageSecret, regionIdentifier))
            {
                try
                {
                    var putRequest1 = new PutObjectRequest
                    {
                        BucketName = AwsBucketName,
                        Key = AwsBucketFileName,
                        ContentBody = data,
                        ContentType = "application/json"
                    };

                    await client.PutObjectAsync(putRequest1);
                }
                catch (AmazonS3Exception amazonS3Exception)
                {
                    if (amazonS3Exception.ErrorCode != null &&
                        (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") || amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
                    {
                        throw new SecurityException("Invalid Amazon S3 credentials - data was not uploaded.", amazonS3Exception);
                    }

                    throw new HttpRequestException("Unspecified error attempting to upload data: " + amazonS3Exception.Message, amazonS3Exception);
                }

                var response = await client.GetObjectAsync(AwsBucketName, AwsBucketFileName);
                using (var reader = new StreamReader(response.ResponseStream))
                {
                    Debug.WriteLine(await reader.ReadToEndAsync());
                }
            }
        }
开发者ID:Benrnz,项目名称:BudgetAnalyser,代码行数:35,代码来源:S3MobileDataUploader.cs

示例2: UploadItemAsync

 private async Task<PutObjectResponse> UploadItemAsync(AmazonS3Client s3Client, string bucketName, string path, CancellationToken token)
 {
     using (var contentStream = _itemChange.CreateContentStream())
     {
         var request = new PutObjectRequest()
         {
             BucketName = bucketName,
             Key = path + _itemChange.Item.Path,
             ContentType = _itemChange.Item.ContentMetadata.ContentType,
             InputStream = contentStream
         };
         return await s3Client.PutObjectAsync(request, token);
     }
 }
开发者ID:bvanschy,项目名称:SourceControlSync,代码行数:14,代码来源:UploadItemCommand.cs

示例3: saveFile

        public static void saveFile()
        {
            string accessKey = "*********************";
            string secretKey = "******************************************";

            AmazonS3Client s3 = new AmazonS3Client(accessKey, secretKey, Amazon.RegionEndpoint.USEast1);

            var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            var fileName = Path.Combine(path, "write.txt");
            PutObjectRequest request = new PutObjectRequest{
            BucketName = "calculatorkrao1",
            Key = "EquationList",
                FilePath = fileName,

            };

            System.Threading.Tasks.Task<PutObjectResponse> response = s3.PutObjectAsync(request);
        }
开发者ID:kavyaraob,项目名称:XamarinApp,代码行数:18,代码来源:cloud.cs

示例4: CopyApplicationToBucketAsync

 public async Task CopyApplicationToBucketAsync(string packagePath)
 {
     using (var s3Client = new AmazonS3Client(credentials, s3ConfigurationProvider.RegionEndpoint))
     {
         var putObjectRequest = new PutObjectRequest
         {
             BucketName = s3ConfigurationProvider.BucketName,
             Key = s3ConfigurationProvider.FullKeyPath,
             FilePath = packagePath
         };
         await s3Client.PutObjectAsync(putObjectRequest);
     }
 }
开发者ID:MaterialDev,项目名称:elastic-beanstalk-deploy,代码行数:13,代码来源:S3Service.cs


注:本文中的Amazon.S3.AmazonS3Client.PutObjectAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。