本文整理汇总了C#中IAmazonS3类的典型用法代码示例。如果您正苦于以下问题:C# IAmazonS3类的具体用法?C# IAmazonS3怎么用?C# IAmazonS3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAmazonS3类属于命名空间,在下文中一共展示了IAmazonS3类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例3: 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
示例4: 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
示例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];
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
示例6: 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
示例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: DoesS3BucketExist
/// <summary>
/// Determines whether an S3 bucket exists or not.
/// This is done by:
/// 1. Creating a PreSigned Url for the bucket (with an expiry date at the end of this decade)
/// 2. Making a HEAD request to the Url
/// </summary>
/// <param name="bucketName">The name of the bucket to check.</param>
/// <param name="s3Client">The Amazon S3 Client to use for S3 specific operations.</param>
/// <returns></returns>
public static bool DoesS3BucketExist(IAmazonS3 s3Client, string bucketName)
{
if (s3Client == null)
{
throw new ArgumentNullException("s3Client", "The s3Client cannot be null!");
}
if (String.IsNullOrEmpty(bucketName))
{
throw new ArgumentNullException("bucketName", "The bucketName cannot be null or the empty string!");
}
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest();
request.BucketName = bucketName;
if (AWSConfigs.S3Config.UseSignatureVersion4)
request.Expires = DateTime.Now.AddDays(6);
else
request.Expires = new DateTime(2019, 12, 31);
request.Verb = HttpVerb.HEAD;
request.Protocol = Protocol.HTTP;
string url = s3Client.GetPreSignedURL(request);
Uri uri = new Uri(url);
HttpWebRequest httpRequest = WebRequest.Create(uri) as HttpWebRequest;
httpRequest.Method = "HEAD";
AmazonS3Client concreteClient = s3Client as AmazonS3Client;
if (concreteClient != null)
{
concreteClient.ConfigureProxy(httpRequest);
}
try
{
using (HttpWebResponse httpResponse = httpRequest.GetResponse() as HttpWebResponse)
{
// If all went well, the bucket was found!
return true;
}
}
catch (WebException we)
{
using (HttpWebResponse errorResponse = we.Response as HttpWebResponse)
{
if (errorResponse != null)
{
HttpStatusCode code = errorResponse.StatusCode;
return code != HttpStatusCode.NotFound &&
code != HttpStatusCode.BadRequest;
}
// The Error Response is null which is indicative of either
// a bad request or some other problem
return false;
}
}
}
开发者ID:wmatveyenko,项目名称:aws-sdk-net,代码行数:65,代码来源:AmazonS3Util.Operations.cs
示例15: CreateABucket
static void CreateABucket(IAmazonS3 client, string bucketName)
{
PutBucketRequest putRequest1 = new PutBucketRequest
{
BucketName = bucketName,
UseClientRegion = true
};
PutBucketResponse response1 = client.PutBucket(putRequest1);
}
开发者ID:PMInova,项目名称:RDSDump,代码行数:10,代码来源:Program.cs
示例16: S3Links
public S3Links(IAmazonS3 amazonS3, IPathManager pathManager, S3StorageClass s3StorageClass)
: base(amazonS3)
{
if (null == pathManager)
throw new ArgumentNullException(nameof(pathManager));
if (null == s3StorageClass)
throw new ArgumentNullException(nameof(s3StorageClass));
_pathManager = pathManager;
_s3StorageClass = s3StorageClass;
}
开发者ID:henricj,项目名称:AwsDedupSync,代码行数:11,代码来源:S3Links.cs
示例17: FindBucketLocation
static string FindBucketLocation(IAmazonS3 client, string bucketName)
{
string bucketLocation;
GetBucketLocationRequest request = new GetBucketLocationRequest()
{
BucketName = bucketName
};
GetBucketLocationResponse response = client.GetBucketLocation(request);
bucketLocation = response.Location.ToString();
return bucketLocation;
}
开发者ID:PMInova,项目名称:RDSDump,代码行数:11,代码来源:Program.cs
示例18: 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
示例19: 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
示例20: Main
public static void Main(string[] args)
{
if (checkRequiredFields())
{
using (client = new AmazonS3Client(RegionEndpoint.USWest2))
{
Console.WriteLine("Listing buckets");
ListingBuckets();
Console.WriteLine("Creating a bucket");
CreateABucket();
Console.WriteLine("Writing an object");
WritingAnObject();
Console.WriteLine("Reading an object");
ReadingAnObject();
Console.WriteLine("Deleting an object");
DeletingAnObject();
Console.WriteLine("Listing objects");
ListingObjects();
}
}
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
开发者ID:awslabs,项目名称:aws-sdk-net-samples,代码行数:29,代码来源:S3Sample.cs
注:本文中的IAmazonS3类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论