本文整理汇总了C#中Amazon.S3.AmazonS3Config类的典型用法代码示例。如果您正苦于以下问题:C# AmazonS3Config类的具体用法?C# AmazonS3Config怎么用?C# AmazonS3Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AmazonS3Config类属于Amazon.S3命名空间,在下文中一共展示了AmazonS3Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadImage
private static S3File UploadImage(string key, Stream inputStream)
{
var s3Config = new AmazonS3Config() { ServiceURL = "http://" + _s3_bucket_region };
using (var cli = new AmazonS3Client(
_s3_access_key,
_s3_secret_access_key,
s3Config))
{
PutObjectRequest req = new PutObjectRequest()
{
BucketName = _s3_bucket_name,
ContentType = "image/jpg",
InputStream = inputStream,
Key = key,
CannedACL = S3CannedACL.PublicRead
};
var response = cli.PutObject(req);
if (response.HttpStatusCode != System.Net.HttpStatusCode.OK)
{
throw new Exception("s3: upload failed.");
}
else
{
return new S3File()
{
Key = key,
Url = HttpUtility.HtmlEncode(
String.Format("http://{0}.{1}/{2}", _s3_bucket_name, _s3_bucket_region, key))
};
}
}
}
示例2: GetStream
public Attachment GetStream(FileInfo file)
{
var bucketInfo = CreateBucketInfo(file.URL);
var awsCredentials = new BasicAWSCredentials(McmModuleConfiguration.Aws.AccessKey, McmModuleConfiguration.Aws.SecretKey);
var s3Config = new AmazonS3Config
{
ServiceURL = bucketInfo.ServiceURL
};
using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client(awsCredentials, s3Config))
{
try
{
var request = new Amazon.S3.Model.GetObjectRequest
{
BucketName = bucketInfo.Bucketname,
Key = bucketInfo.Key,
};
var response = client.GetObject(request);
return new Attachment
{
FileName = file.OriginalFilename,
ContentType = file.MimeType,
Disposable = response,
Stream = response.ResponseStream
};
}
catch (System.Exception e)
{
throw new UnhandledException(string.Format("bucket: {0}, key: {1}, service_url: {2}", bucketInfo.Bucketname, bucketInfo.Key, bucketInfo.ServiceURL), e);
}
}
}
示例3: NewsMethods
public NewsMethods()
{
accessKeyID = "AKIAIWFK6YSYC34OEFJQ";
secretAccessKeyID = "STxTfkHrJTRcwFmrKAsN7eelCs81BhLiPlnIjdkq";
config = new AmazonS3Config();
config.ServiceURL = "s3.amazonaws.com";
}
示例4: S3Reader2
public S3Reader2(NameValueCollection args )
{
s3config = new AmazonS3Config();
buckets = args["buckets"];
vpath = args["prefix"];
asVpp = NameValueCollectionExtensions.Get(args, "vpp", true);
Region = args["region"] ?? "us-east-1";
s3config.UseHttp = !NameValueCollectionExtensions.Get(args, "useSsl", false);
if (!string.IsNullOrEmpty(args["accessKeyId"]) && !string.IsNullOrEmpty(args["secretAccessKey"])) {
S3Client = new AmazonS3Client(args["accessKeyId"], args["secretAccessKey"], s3config);
} else {
S3Client = new AmazonS3Client(null, s3config);
}
includeModifiedDate = NameValueCollectionExtensions.Get(args, "includeModifiedDate", includeModifiedDate);
includeModifiedDate = NameValueCollectionExtensions.Get(args, "checkForModifiedFiles", includeModifiedDate);
RequireImageExtension = NameValueCollectionExtensions.Get(args, "requireImageExtension", RequireImageExtension);
UntrustedData = NameValueCollectionExtensions.Get(args, "untrustedData", UntrustedData);
CacheUnmodifiedFiles = NameValueCollectionExtensions.Get(args, "cacheUnmodifiedFiles", CacheUnmodifiedFiles);
}
示例5: S3FileSystem
public S3FileSystem(IPsCmdletLogger logger, string accessKey, string secret, AmazonS3Config config)
{
Logger = logger ?? new TraceLogger();
S3Client = new AmazonS3Client(accessKey, secret, config);
TransferUtility = new TransferUtility(S3Client);
FileLoader = (fileFullName) => new FileWrap().Open(fileFullName, FileMode.Open, FileAccess.ReadWrite);
}
示例6: CreateFileFromStream
public static bool CreateFileFromStream(Stream InputStream, string FileName, string _bucketName = "doc2xml")
{
bool _saved=false;
try
{
IAmazonS3 client;
AmazonS3Config objCon = new AmazonS3Config() ;
objCon.RegionEndpoint = RegionEndpoint.USEast1;
using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(_awsAccessKey, _awsSecretKey,objCon))
{
var request = new PutObjectRequest()
{
BucketName = _bucketName,
CannedACL = S3CannedACL.PublicRead,//PERMISSION TO FILE PUBLIC ACCESIBLE
Key = string.Format("{0}", FileName),
InputStream = InputStream//SEND THE FILE STREAM
};
client.PutObject(request);
_saved = true;
}
}
catch (Exception ex)
{
ex.ToString();
}
return _saved;
}
示例7: S3Reader
public S3Reader(NameValueCollection args )
{
var S3Config = new AmazonS3Config();
buckets = args["buckets"];
vpath = args["prefix"];
asVpp = NameValueCollectionExtensions.Get(args, "vpp", true);
S3Config.CommunicationProtocol = NameValueCollectionExtensions.Get(args, "useSsl", false) ? Amazon.S3.Model.Protocol.HTTPS : Amazon.S3.Model.Protocol.HTTP;
S3Config.UseSecureStringForAwsSecretKey = false;
if (!string.IsNullOrEmpty(args["accessKeyId"]) && !string.IsNullOrEmpty(args["secretAccessKey"])) {
S3Client = new AmazonS3Client(args["accessKeyId"], args["secretAccessKey"], S3Config);
} else {
S3Client = new AmazonS3Client(null,S3Config);
}
includeModifiedDate = NameValueCollectionExtensions.Get(args, "includeModifiedDate", includeModifiedDate);
includeModifiedDate = NameValueCollectionExtensions.Get(args, "checkForModifiedFiles", includeModifiedDate);
RequireImageExtension = NameValueCollectionExtensions.Get(args, "requireImageExtension", RequireImageExtension);
UntrustedData = NameValueCollectionExtensions.Get(args, "untrustedData", UntrustedData);
CacheUnmodifiedFiles = NameValueCollectionExtensions.Get(args, "cacheUnmodifiedFiles", CacheUnmodifiedFiles);
}
示例8: InitS3Client
public static AmazonS3 InitS3Client()
{
string accessKeyID = WebConfig.Get("awsaccesskey");
string secretAccessKeyID = WebConfig.Get("awssecretkey");
AmazonS3Config config = new AmazonS3Config();
config.CommunicationProtocol = Protocol.HTTP;
return Amazon.AWSClientFactory.CreateAmazonS3Client(accessKeyID.Trim(), secretAccessKeyID.Trim(), config);
}
示例9: S3ClientCache
internal S3ClientCache(AWSCredentials credentials, AmazonS3Config config)
{
this.credentials = credentials;
this.config = config;
this.clientsByRegion = new Dictionary<string,AmazonS3Client>(StringComparer.OrdinalIgnoreCase);
this.transferUtilitiesByRegion = new Dictionary<string,TransferUtility>(StringComparer.OrdinalIgnoreCase);
}
示例10: CreateS3Client
private static AmazonS3 CreateS3Client()
{
var config = new AmazonS3Config()
.WithCommunicationProtocol(Protocoll)
.WithServiceURL(ServiceUrl);
var client = AWSClientFactory.CreateAmazonS3Client(AwsAccessKey, AwsSecretAccessKey, config);
return client;
}
示例11: AmazonS3
public AmazonS3(string keyId, string secretKey, Database db)
: base(db)
{
s3Config = new AmazonS3Config();
s3Config.ServiceURL = "s3.amazonaws.com";
s3Config.CommunicationProtocol = Protocol.HTTPS;
client = AWSClientFactory.CreateAmazonS3Client(keyId, secretKey, s3Config);
}
示例12: CraneChatS3Uploader
public CraneChatS3Uploader()
{
m_CloudFrontRoot = new Uri(ConfigurationManager.AppSettings["CloudFrontRoot"]);
m_BucketName = ConfigurationManager.AppSettings["BucketName"];
AmazonS3Config s3Config = new AmazonS3Config().WithServiceURL(ConfigurationManager.AppSettings["S3ServiceURL"].ToString());
AmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client(s3Config);
m_s3transferUtility = new TransferUtility(s3Client);
}
示例13: Create
internal static S3RequestEventArgs Create(S3Request request, AmazonS3Config config)
{
S3RequestEventArgs args = new S3RequestEventArgs
{
OriginalRequest = request,
Headers = request.Headers,
ServiceURL = config.ServiceURL
};
return args;
}
示例14: AmazonS3Helper
/// <summary>
/// Initializes a new instance of the <see cref="AmazonS3Helper" /> class using the specified credentials.
/// </summary>
/// <param name="keyPublic">The public Amazon S3 key.</param>
/// <param name="keySecret">The secret Amazon S3 key.</param>
public AmazonS3Helper(String keyPublic, String keySecret, String bucket)
{
_keyPublic = keyPublic;
_keySecret = keySecret;
_bucket = bucket;
ValidateConfiguration();
var s3Config = new AmazonS3Config { RegionEndpoint = RegionEndpoint.USEast1 };
_client = AWSClientFactory.CreateAmazonS3Client(keyPublic, _keySecret, s3Config);
}
示例15: GetAmazonCleint
private static IAmazonS3 GetAmazonCleint()
{
BUCKET_NAME = Startup.Configuration["AWS:BucketName"];
AWS_ACCESS_KEY = Startup.Configuration["AWS:AccessKey"];
AWS_SECRET_KEY = Startup.Configuration["AWS:SecretKey"];
AmazonS3Config config = new AmazonS3Config() { };
config.RegionEndpoint = RegionEndpoint.EUCentral1;
Amazon.S3.IAmazonS3 client = AWSClientFactory.CreateAmazonS3Client(AWS_ACCESS_KEY, AWS_SECRET_KEY, config);
AWSConfigs.S3UseSignatureVersion4 = true;
return client;
}