• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# S3.AmazonS3Config类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



AmazonS3Config类属于Amazon.S3命名空间,在下文中一共展示了AmazonS3Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
                    };
                }
            }
        }
开发者ID:teo-mateo,项目名称:sdc,代码行数:33,代码来源:S3.cs


示例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);
				}
			}
		}
开发者ID:CHAOS-Community,项目名称:CHAOS.Portal.MCM,代码行数:35,代码来源:S3DownloadStrategy.cs


示例3: NewsMethods

 public NewsMethods()
 {
     accessKeyID = "AKIAIWFK6YSYC34OEFJQ";
     secretAccessKeyID = "STxTfkHrJTRcwFmrKAsN7eelCs81BhLiPlnIjdkq";
     config = new AmazonS3Config();
     config.ServiceURL = "s3.amazonaws.com";
 }
开发者ID:abrahamkapambwe,项目名称:RSSNews,代码行数:7,代码来源:NewsMethods.cs


示例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);
        }
开发者ID:stukalin,项目名称:ImageResizer,代码行数:28,代码来源:S3Reader.cs


示例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);
 }
开发者ID:rnarayana,项目名称:PowerUp,代码行数:7,代码来源:S3FileSystem.cs


示例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;
        }
开发者ID:LawrenceAntony,项目名称:Docx2XML,代码行数:30,代码来源:AWSS3.cs


示例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);
        }
开发者ID:eakova,项目名称:resizer,代码行数:27,代码来源:S3Reader.cs


示例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);
 }
开发者ID:uxsniper,项目名称:NeuReg,代码行数:8,代码来源:UtilityHelper.cs


示例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);
        }
开发者ID:rossmas,项目名称:aws-sdk-net,代码行数:8,代码来源:S3ClientCache.cs


示例10: CreateS3Client

        private static AmazonS3 CreateS3Client()
        {
            var config = new AmazonS3Config()
                      .WithCommunicationProtocol(Protocoll)
                      .WithServiceURL(ServiceUrl);

              var client = AWSClientFactory.CreateAmazonS3Client(AwsAccessKey, AwsSecretAccessKey, config);
              return client;
        }
开发者ID:nrazon,项目名称:S3Emulator,代码行数:9,代码来源:Program.cs


示例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);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:9,代码来源:AmazonS3.cs


示例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);
        }
开发者ID:victorzzz,项目名称:CraneChat,代码行数:9,代码来源:CraneChatS3Uploader.cs


示例13: Create

 internal static S3RequestEventArgs Create(S3Request request, AmazonS3Config config)
 {
     S3RequestEventArgs args = new S3RequestEventArgs
     {
         OriginalRequest = request,
         Headers = request.Headers,
         ServiceURL = config.ServiceURL
     };
     return args;
 }
开发者ID:kyleeverson,项目名称:aws-sdk-for-net,代码行数:10,代码来源:RequestHandler.cs


示例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);
        }
开发者ID:Rychard,项目名称:SqlServerBackup,代码行数:15,代码来源:AmazonS3Helper.cs


示例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;
 }
开发者ID:amera7md,项目名称:Rankdit,代码行数:11,代码来源:PostService.cs


示例16: CreateClientUsingProxy

 //[Fact]
 public void CreateClientUsingProxy()
 {
     var config = new AmazonS3Config
     {
         ProxyCredentials = new NetworkCredential("1", "1"),
         RegionEndpoint = RegionEndpoint.USEast1
     };
     config.SetWebProxy(new WebProxy("http://localhost:8888/"));
     client = new AmazonS3Client(config);
     ListBuckets();
 }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:12,代码来源:WebProxyTest.cs


示例17: S3StorageProvider

        public S3StorageProvider(IOrchardServices services)
        {
            Services = services;
            _S3Config = new AmazonS3Config()
            {
                ServiceURL = "s3.amazonaws.com",
                CommunicationProtocol = Amazon.S3.Model.Protocol.HTTP,
            };

            T = NullLocalizer.Instance;
        }
开发者ID:jonparker,项目名称:Orchard,代码行数:11,代码来源:S3StorageProvider.cs


示例18: AmazonStorageProvider

        public AmazonStorageProvider(AmazonProviderOptions options)
        {
            _serviceUrl = options.ServiceUrl ?? DefaultServiceUrl;
            _bucket = options.Bucket;

            var S3Config = new AmazonS3Config
            {
                ServiceURL = _serviceUrl            
            };

            _s3Client = new AmazonS3Client(options.PublicKey, options.SecretKey, S3Config);
        }
开发者ID:2020IP,项目名称:TwentyTwenty.Storage,代码行数:12,代码来源:AmazonStorageProvider.cs


示例19: UseAwsSdk

        /// <summary>
        /// Uses the AWS SDK for .NET to talk to Tier 3 Object Storage
        /// </summary>
        private static void UseAwsSdk()
        {
            Console.WriteLine(":: Calling Tier 3 Object Storage from AWS SDK for .NET ::");
            Console.WriteLine();

            //create configuration that points to different URL
            AmazonS3Config config = new AmazonS3Config()
            {
                ServiceURL = "ca.tier3.io"
            };

            AmazonS3Client client = new AmazonS3Client(adminAccessKey, adminAccessSecret, config);

            /*
             * List buckets
             */
            Console.WriteLine("ACTION: List all the buckets");
            ListBucketsResponse resp = client.ListBuckets();

            foreach (S3Bucket bucket in resp.Buckets)
            {
                Console.WriteLine("-" + bucket.BucketName);
            }

            Console.WriteLine();

            /*
             * List objects in a single bucket
             */
            Console.WriteLine("ACTION: Enter the name of a bucket to open: ");
            string inputbucket = Console.ReadLine();

            ListObjectsRequest objReq = new ListObjectsRequest() { BucketName = inputbucket };
            ListObjectsResponse objResp = client.ListObjects(objReq);

            foreach (S3Object obj in objResp.S3Objects)
            {
                Console.WriteLine("-" + obj.Key);
            }

            /*
             * Upload object to bucket
             */
            //Console.Write("Type [Enter] to upload an object to the opened bucket");
            //Console.ReadLine();

            //PutObjectRequest putReq = new PutObjectRequest() { BucketName = inputbucket, FilePath = @"C:\image.png", ContentType = "image/png" };
            //PutObjectResponse putResp = client.PutObject(putReq);

            //Console.WriteLine("Object uploaded.");
            Console.ReadLine();
        }
开发者ID:gavin-lai,项目名称:Examples,代码行数:55,代码来源:Program.cs


示例20: BloomS3Client

 public BloomS3Client(string bucketName)
 {
     _bucketName = bucketName;
     _s3Config = new AmazonS3Config { ServiceURL = "https://s3.amazonaws.com" };
     var proxy = new ProxyManager();
     if (!string.IsNullOrEmpty(proxy.Hostname))
     {
         _s3Config.ProxyHost = proxy.Hostname;
         _s3Config.ProxyPort = proxy.Port;
         if (!string.IsNullOrEmpty(proxy.Username))
             _s3Config.ProxyCredentials = new NetworkCredential(proxy.Username, proxy.Password);
     }
 }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:13,代码来源:BloomS3Client.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Model.CopyObjectRequest类代码示例发布时间:2022-05-24
下一篇:
C# S3.AmazonS3Client类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap