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


C# IAmazonS3类代码示例

本文整理汇总了C#中IAmazonS3的典型用法代码示例。如果您正苦于以下问题:C# IAmazonS3类的具体用法?C# IAmazonS3怎么用?C# IAmazonS3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: MultipartUploadCommand

        /// <summary>
        /// Initializes a new instance of the <see cref="MultipartUploadCommand"/> class.
        /// </summary>
        /// <param name="s3Client">The s3 client.</param>
        /// <param name="config">The config object that has the number of threads to use.</param>
        /// <param name="fileTransporterRequest">The file transporter request.</param>
        internal MultipartUploadCommand(IAmazonS3 s3Client, TransferUtilityConfig config, TransferUtilityUploadRequest fileTransporterRequest)
        {
            this._config = config;

            if (fileTransporterRequest.IsSetFilePath())
            {
                _logger.DebugFormat("Beginning upload of file {0}.", fileTransporterRequest.FilePath);
            }
            else
            {
                _logger.DebugFormat("Beginning upload of stream.");
            }

            this._s3Client = s3Client;
            this._fileTransporterRequest = fileTransporterRequest;
            this._contentLength = this._fileTransporterRequest.ContentLength;

            if (fileTransporterRequest.IsSetPartSize())
                this._partSize = fileTransporterRequest.PartSize;
            else
                this._partSize = calculatePartSize(this._contentLength);

            if (fileTransporterRequest.InputStream != null)
            {
                if (fileTransporterRequest.AutoResetStreamPosition && fileTransporterRequest.InputStream.CanSeek)
                {
                    fileTransporterRequest.InputStream.Seek(0, SeekOrigin.Begin);
                }
            }

            _logger.DebugFormat("Upload part size {0}.", this._partSize);
        }
开发者ID:jeffersonjhunt,项目名称:aws-sdk-net,代码行数:38,代码来源:MultipartUploadCommand.cs

示例2: GetHeadAsync

 internal static async Task<GetHeadResponse> GetHeadAsync(IAmazonS3 s3Client, IClientConfig config, string url, string header)
 {
     if (s3Client != null)
     {
         using (var httpClient = GetHttpClient(config))
         {
             var request = new HttpRequestMessage(HttpMethod.Head, url);
             var response = await httpClient.SendAsync(request).ConfigureAwait(false);
             foreach (var headerPair in response.Headers)
             {
                 if (string.Equals(headerPair.Key, HeaderKeys.XAmzBucketRegion, StringComparison.OrdinalIgnoreCase))
                 {
                     foreach (var value in headerPair.Value)
                     {
                         // If there's more than one there's something really wrong.
                         // So just use the first one anyway.
                         return new GetHeadResponse
                         {
                             HeaderValue = value,
                             StatusCode = response.StatusCode
                         };
                     }
                 }
             }
         }
     }
     return null;
 }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:28,代码来源:AmazonS3HttpUtil.cs

示例3: S3VirtualPathProvider

 public S3VirtualPathProvider(IAmazonS3 client, string bucketName, IAppHost appHost)
     : base(appHost)
 {
     this.AmazonS3 = client;
     this.BucketName = bucketName;
     this.rootDirectory = new S3VirtualDirectory(this, null);
 }
开发者ID:derFunk,项目名称:ServiceStack.Aws,代码行数:7,代码来源:S3VirtualPathProvider.cs

示例4: SimpleUploadCommand

 internal SimpleUploadCommand(IAmazonS3 s3Client, TransferUtilityConfig config, TransferUtilityUploadRequest fileTransporterRequest)
 {
     this._s3Client = s3Client;
     this._config = config;
     this._fileTransporterRequest = fileTransporterRequest;
     var fileName = fileTransporterRequest.FilePath;
 }
开发者ID:sadiqj,项目名称:aws-sdk-xamarin,代码行数:7,代码来源:SimpleUploadCommand.cs

示例5: ToTransportMessage

		public static TransportMessage ToTransportMessage(this SqsTransportMessage sqsTransportMessage, IAmazonS3 amazonS3, SqsConnectionConfiguration connectionConfiguration)
        {
            var messageId = sqsTransportMessage.Headers[Headers.MessageId];

			var result = new TransportMessage(messageId, sqsTransportMessage.Headers);

            if (!string.IsNullOrEmpty(sqsTransportMessage.S3BodyKey))
            {
                var s3GetResponse = amazonS3.GetObject(connectionConfiguration.S3BucketForLargeMessages, sqsTransportMessage.S3BodyKey);
                result.Body = new byte[s3GetResponse.ResponseStream.Length];
                using (BufferedStream bufferedStream = new BufferedStream(s3GetResponse.ResponseStream))
                {
                    int count;
                    int transferred = 0;
                    while ((count = bufferedStream.Read(result.Body, transferred, 8192)) > 0)
                    {
                        transferred += count;
                    }
                }
            }
            else
			{
				result.Body = Convert.FromBase64String(sqsTransportMessage.Body);
			}

            result.TimeToBeReceived = sqsTransportMessage.TimeToBeReceived;

			if (sqsTransportMessage.ReplyToAddress != null)
			{
				result.Headers[Headers.ReplyToAddress] = sqsTransportMessage.ReplyToAddress.ToString();
			}

            return result;
        }
开发者ID:briangoncalves,项目名称:NServiceBus.AmazonSQS,代码行数:34,代码来源:SqsMessageExtensions.cs

示例6: ToTransportMessage

		public static TransportMessage ToTransportMessage(this SqsTransportMessage sqsTransportMessage, IAmazonS3 amazonS3, SqsConnectionConfiguration connectionConfiguration)
        {
            var messageId = sqsTransportMessage.Headers[Headers.MessageId];

			var result = new TransportMessage(messageId, sqsTransportMessage.Headers);
			
			if (!string.IsNullOrEmpty(sqsTransportMessage.S3BodyKey))
			{
				var s3GetResponse = amazonS3.GetObject(connectionConfiguration.S3BucketForLargeMessages, sqsTransportMessage.S3BodyKey);
				result.Body = new byte[s3GetResponse.ResponseStream.Length];
				s3GetResponse.ResponseStream.Read(result.Body, 0, result.Body.Length);
			}
			else
			{
				result.Body = Convert.FromBase64String(sqsTransportMessage.Body);
			}

            result.TimeToBeReceived = sqsTransportMessage.TimeToBeReceived;

			if (sqsTransportMessage.ReplyToAddress != null)
			{
				result.Headers[Headers.ReplyToAddress] = sqsTransportMessage.ReplyToAddress.ToString();
			}

            return result;
        }
开发者ID:GCMGrosvenor,项目名称:NServiceBus.AmazonSQS-1,代码行数:26,代码来源:SqsMessageExtensions.cs

示例7: S3PutBase

        protected S3PutBase(IAmazonS3 amazonS3)
        {
            if (null == amazonS3)
                throw new ArgumentNullException(nameof(amazonS3));

            AmazonS3 = amazonS3;
        }
开发者ID:henricj,项目名称:AwsDedupSync,代码行数:7,代码来源:S3PutBase.cs

示例8: AbortMultipartUploadsCommand

 internal AbortMultipartUploadsCommand(IAmazonS3 s3Client, string bucketName, DateTime initiateDate, TransferUtilityConfig config)
 {
     this._s3Client = s3Client;
     this._bucketName = bucketName;
     this._initiatedDate = initiateDate;
     this._config = config;
 }
开发者ID:virajs,项目名称:aws-sdk-net,代码行数:7,代码来源:AbortMultipartUploadsCommand.async.cs

示例9: AwsManager

        public AwsManager(IAmazonS3 amazonS3, IPathManager pathManager)
        {
            if (null == amazonS3)
                throw new ArgumentNullException(nameof(amazonS3));
            if (null == pathManager)
                throw new ArgumentNullException(nameof(pathManager));

            _pathManager = pathManager;
            _amazonS3 = amazonS3;

            var storageClass = S3StorageClass.Standard;
            var storageClassString = ConfigurationManager.AppSettings["AwsStorageClass"];

            if (!string.IsNullOrWhiteSpace(storageClassString))
                storageClass = S3StorageClass.FindValue(storageClassString);

            var blobStorageClass = storageClass;
            var blobStorageClassString = ConfigurationManager.AppSettings["AwsBlobStorageClass"];

            if (!string.IsNullOrWhiteSpace(blobStorageClassString))
                blobStorageClass = S3StorageClass.FindValue(blobStorageClassString);

            var linkStorageClass = storageClass;
            var linkStorageClassString = ConfigurationManager.AppSettings["AwsLinkStorageClass"];

            if (!string.IsNullOrWhiteSpace(linkStorageClassString))
                linkStorageClass = S3StorageClass.FindValue(linkStorageClassString);

            _s3Blobs = new S3Blobs(amazonS3, pathManager, blobStorageClass);
            _s3Links = new S3Links(amazonS3, pathManager, linkStorageClass);
        }
开发者ID:henricj,项目名称:AwsDedupSync,代码行数:31,代码来源:AwsManager.cs

示例10: MultipartUploadCommand

        /// <summary>
        /// Initializes a new instance of the <see cref="MultipartUploadCommand"/> class.
        /// </summary>
        /// <param name="s3Client">The s3 client.</param>
        /// <param name="config">The config object that has the number of threads to use.</param>
        /// <param name="fileTransporterRequest">The file transporter request.</param>
        internal MultipartUploadCommand(IAmazonS3 s3Client, TransferUtilityConfig config, TransferUtilityUploadRequest fileTransporterRequest)
        {
            this._config = config;

            if (fileTransporterRequest.IsSetFilePath())
            {
                _logger.DebugFormat("Beginning upload of file {0}.", fileTransporterRequest.FilePath);
            }
            else
            {
                _logger.DebugFormat("Beginning upload of stream.");
            }

            this._s3Client = s3Client;
            this._fileTransporterRequest = fileTransporterRequest;
            this._contentLength = this._fileTransporterRequest.ContentLength;



            if (fileTransporterRequest.IsSetPartSize())
                this._partSize = fileTransporterRequest.PartSize;
            else
                this._partSize = calculatePartSize(this._contentLength);

            _logger.DebugFormat("Upload part size {0}.", this._partSize);
        }
开发者ID:rinselmann,项目名称:aws-sdk-net,代码行数:32,代码来源:MultipartUploadCommand.cs

示例11: CacheAlbum

        private async Task<Album> CacheAlbum(HttpClient httpClient, IAmazonS3 s3Client, JsonAlbum jsonAlbum, IList<string> cachedObjects, CancellationToken ctx)
        {
            var image = jsonAlbum.Image.Where(i => i.Size == JsonAlbumImageSize.Medium && i.Url != null).SingleOrDefault();
            if (image == null)
            {
                return null;
            }

            var album = new Album
            {
                Artist = jsonAlbum.Artist,
                Name = jsonAlbum.Name,
                Playcount = jsonAlbum.Playcount,
                Rank = jsonAlbum.Attributes.Rank,
                Url = jsonAlbum.Url
            };
            var objectKey = album.ToString().ToSlug();

            album.Thumbnail = new Uri($"https://s3-eu-west-1.amazonaws.com/{BucketName}/{objectKey}");

            // If the album art was cached already, return
            if (cachedObjects.Any(k => k == objectKey))
            {
                return album;
            }

            string mediaType;
            byte[] imageBytes;
            try
            {
                logger.LogInformation($"Downloading art for {album}");
                var response = await httpClient.GetAsync(image.Url, ctx);
                mediaType = response.Content.Headers?.ContentType?.MediaType;
                imageBytes = await response.Content.ReadAsByteArrayAsync();
            }
            catch (Exception ex)
            {
                // If anything happened here, log and continue. We don't want to retry.
                logger.LogWarning($"Hit exception whilst trying to download art for {album}", ex);
                return null;
            }

            PutObjectResponse putResponse;
            using (var ms = new MemoryStream(imageBytes))
            {
                logger.LogVerbose($"Storing art for {album}");
                putResponse = await s3Client.PutObjectAsync(new PutObjectRequest
                {
                    BucketName = BucketName,
                    ContentType = mediaType,
                    InputStream = ms,
                    Key = objectKey,
                    StorageClass = S3StorageClass.ReducedRedundancy,
                    CannedACL = S3CannedACL.PublicRead
                }, ctx);
            }

            return album;
        }
开发者ID:alanedwardes,项目名称:aeblog,代码行数:59,代码来源:AlbumCacheTask.cs

示例12: CodeDeployProcessor

 public CodeDeployProcessor(IApplicationEnvironment appEnv, IConfiguration configuration,  UtilityService utilties,
     IAmazonS3 s3Client, IAmazonCodeDeploy codeDeployClient)
 {
     this.AppEnv = appEnv;
     this.Configuration = configuration;
     this.Utilities = utilties;
     this.S3Client = s3Client;
     this.CodeDeployClient = codeDeployClient;
 }
开发者ID:jamisliao,项目名称:aws-sdk-net-samples,代码行数:9,代码来源:CodeDeployProcessor.cs

示例13: AmazonS3StorageProvider

 public AmazonS3StorageProvider(IAmazonS3StorageConfiguration amazonS3StorageConfiguration)
 {
     _amazonS3StorageConfiguration = amazonS3StorageConfiguration;
     var cred = new BasicAWSCredentials(_amazonS3StorageConfiguration.AWSAccessKey, _amazonS3StorageConfiguration.AWSSecretKey);
     //TODO: aws region to config
     _client = new AmazonS3Client(cred, RegionEndpoint.USEast1);
     var config = new TransferUtilityConfig();
     _transferUtility = new TransferUtility(_client, config);
 }
开发者ID:SmartFire,项目名称:Amba.AmazonS3,代码行数:9,代码来源:AmazonS3StorageProvider.cs

示例14: ScreenshotUploader

 public ScreenshotUploader(Secrets secrets, string userToken, IMessageBus messageBus)
 {
     this._bucket = secrets.Name;
     this._token = userToken;
     this._client = new AmazonS3Client(secrets.Key, secrets.Secret, RegionEndpoint.USEast1);
     this._messageBus = messageBus;
 }
开发者ID:kevinbrill,项目名称:tempusgameit-client,代码行数:7,代码来源:ScreenshotUploader.cs

示例15: AlbumCacheTask

 public AlbumCacheTask(ILastfmClientFactory lastfmFactory, IS3ClientFactory s3Factory, ICacheProvider cacheProvider, ILogger<AlbumCacheTask> logger)
 {
     this.s3Client = s3Factory.CreateS3Client();
     this.lastfmClient = lastfmFactory.CreateLastfmClient();
     this.cacheProvider = cacheProvider;
     this.logger = logger;
 }
开发者ID:alanedwardes,项目名称:aeblog,代码行数:7,代码来源:AlbumCacheTask.cs


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