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

C# AmazonS3类代码示例

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

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



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

示例1: SetInstance

 private static void SetInstance()
 {
     if(theAmazonClient == null) {
         theAmazonClient =
             Amazon.AWSClientFactory.CreateAmazonS3Client(Configuration.SiteConfiguration.AWSAccessKey(), Configuration.SiteConfiguration.AWSSecretKey());
     }
 }
开发者ID:henryksarat,项目名称:Have-A-Voice,代码行数:7,代码来源:AWSHelper.cs


示例2: Main

        public static void Main(string[] args)
        {
            if (checkRequiredFields())
            {
                using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(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:bernardoleary,项目名称:MyBigBro,代码行数:29,代码来源:S3Sample.cs


示例3: PhysicallyDeletePhoto

        public static S3Response PhysicallyDeletePhoto(AmazonS3 anS3Client, string aBucketName, string aFileName)
        {
            DeleteObjectRequest myDeleteRequest = new DeleteObjectRequest();
            myDeleteRequest.WithBucketName(aBucketName).WithKey(aFileName);

            return anS3Client.DeleteObject(myDeleteRequest);
        }
开发者ID:henryksarat,项目名称:Have-A-Voice,代码行数:7,代码来源:AWSPhotoHelper.cs


示例4: S3FileSystem

 //For testing - allows mocking of files and s3
 public S3FileSystem(AmazonS3 s3Client, Func<string, IFileStreamWrap> fileLoader)
 {
     Logger = new TraceLogger();
     S3Client = s3Client;
     TransferUtility = new TransferUtility(s3Client);
     FileLoader = fileLoader;
 }
开发者ID:rnarayana,项目名称:PowerUp,代码行数:8,代码来源:S3FileSystem.cs


示例5: S3StorageProvider

 public S3StorageProvider(AmazonS3 s3, string bucket, string rootKey = null)
 {
     _s3 = s3;
     _bucket = bucket;
     _rootKey = SanitizeKey(rootKey ?? "");
     MaxParallelStreams = 4;
 }
开发者ID:glueckkanja,项目名称:yas4,代码行数:7,代码来源:S3StorageProvider.cs


示例6: Main

        public static void Main(string[] args)
        {
            _threadPool = new Semaphore(MaxThreads, MaxThreads);

              using (_s3Client = AWSClientFactory.CreateAmazonS3Client(ConfigurationManager.AppSettings["AWSAccessKey"], ConfigurationManager.AppSettings["AWSSecretKey"]))
              {
            for (int level = StartLevel; level <= EndLevel; ++level)
            {
              double tileSize = WebMercatorDelta * Math.Pow(2, 1 - level);

              int startRow = Convert.ToInt32(Math.Truncate((WebMercatorDelta - ExtentMaxY) / tileSize)) - TilePaddingY;
              int endRow = Convert.ToInt32(Math.Truncate((WebMercatorDelta - ExtentMinY) / tileSize)) + 1 + TilePaddingY;
              int startColumn = Convert.ToInt32(Math.Truncate((ExtentMinX + WebMercatorDelta) / tileSize)) - TilePaddingX;
              int endColumn = Convert.ToInt32(Math.Truncate((ExtentMaxX + WebMercatorDelta) / tileSize)) + 1 + TilePaddingX;

              for (int r = startRow; r <= endRow; ++r)
              {
            for (int c = startColumn; c <= endColumn; ++c)
            {
              _threadPool.WaitOne();

              Thread t = new Thread(new ParameterizedThreadStart(CopyImage));
              t.Start(new UserData(level, r, c));

              Console.Write(String.Format("{0}Level {1} Row {2} Column {3}", new String('\b', 40), level, r, c).PadRight(80));
            }
              }
            }
              }

              Console.WriteLine((new String('\b', 40) + "Done").PadRight(80));
              Console.Read();
        }
开发者ID:agrc,项目名称:tile-etl,代码行数:33,代码来源:EtlToS3.cs


示例7: MessageGearsAwsClient

 /// <summary>
 /// Used to create a new instance of the MessageGears client.
 /// </summary>
 /// <param name="props">
 /// Contains the credentials needed to access MessageGears, Amazon S3, and Amazon SQS.<see cref="MessageGearsProperties"/>
 /// </param>
 public MessageGearsAwsClient(MessageGearsAwsProperties props)
 {
     this.properties = props;
     this.sqs = new AmazonSQSClient(properties.MyAWSAccountKey, properties.MyAWSSecretKey);
     this.s3 = new AmazonS3Client(properties.MyAWSAccountKey, properties.MyAWSSecretKey);
     log.Info("MessageGears AWS client initialized");
 }
开发者ID:messagegears,项目名称:messagegears-csharp-sdk,代码行数:13,代码来源:MessageGearsAwsClient.cs


示例8: 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(AmazonS3 s3Client, TransferUtilityConfig config, TransferUtilityUploadRequest fileTransporterRequest)
        {
            this._config = config;

            if (fileTransporterRequest.IsSetFilePath())
            {
                this._logger.DebugFormat("Beginning upload of file {0}.", fileTransporterRequest.FilePath);
            }
            else
            {
                this._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);

            this._logger.DebugFormat("Upload part size {0}.", this._partSize);
        }
开发者ID:friism,项目名称:AWS-SDK-for-.NET,代码行数:32,代码来源:MultipartUploadCommand.cs


示例9: ResizeImageAndUpload

 public static void ResizeImageAndUpload(AmazonS3 anAmazonS3Client, string aBucketName, string aCurrentPhotoName, string aNewImageName, int aSize)
 {
     GetObjectRequest myGetRequest = new GetObjectRequest().WithBucketName(aBucketName).WithKey(aCurrentPhotoName);
     GetObjectResponse myResponse = anAmazonS3Client.GetObject(myGetRequest);
     Stream myStream = myResponse.ResponseStream;
     ResizeAndUpload(myStream, anAmazonS3Client, aBucketName, aNewImageName, aSize);
 }
开发者ID:henryksarat,项目名称:Have-A-Voice,代码行数:7,代码来源:AWSPhotoHelper.cs


示例10: S3Storage

        /// <summary>
        /// A Wrapper for the AWS.net SDK
        /// </summary>
        public S3Storage()
        {
            var accessKeyId = _dbContext.Key.SingleOrDefault(k => k.Name == "AccessKeyId").Data;
            var secretAccessKey = _dbContext.Key.SingleOrDefault(k => k.Name == "SecretAccessKey").Data;

            _client = AWSClientFactory.CreateAmazonS3Client(accessKeyId, secretAccessKey, RegionEndpoint.USEast1);
        }
开发者ID:0xdeafcafe,项目名称:Onyx,代码行数:10,代码来源:S3Storage.cs


示例11: Main

        public static void Main(string[] args)
        {
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            accessKeyID = appConfig["AWSAccessKey"];
            secretAccessKeyID = appConfig["AWSSecretKey"];

            using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKeyID, secretAccessKeyID))
            {
                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:ksikes,项目名称:Amazon.Powershell,代码行数:31,代码来源:S3Sample.cs


示例12: S3FetchClient

 public S3FetchClient(IHttpRetryService httpRetryService,
     IFileSystem fileSystem,
     AmazonS3 s3)
 {
     this.httpRetryService = httpRetryService;
     this.fileSystem = fileSystem;
     this.s3 = s3;
 }
开发者ID:erikols,项目名称:nget,代码行数:8,代码来源:S3FetchClient.cs


示例13: DeleteFile

 public static void DeleteFile(AmazonS3 Client, string filekey)
 {
     DeleteObjectRequest request = new DeleteObjectRequest()
     {
         BucketName = BUCKET_NAME,
         Key = filekey
     };
     S3Response response = Client.DeleteObject(request);
 }
开发者ID:xescrp,项目名称:breinstormin,代码行数:9,代码来源:S3Engine.cs


示例14: Main

        public static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();
            log.Info("Initializing and connecting to AWS...");

            s3 = AWSClientFactory.CreateAmazonS3Client(RegionEndpoint.USWest1);
            indexer = new FileIndexer("Files");
            indexer.Index();

            s3indexer = new S3Indexer(Settings.Default.BucketName, Settings.Default.FolderName, "S3Tmp", s3);
            s3indexer.Index();

            log.Info("Comparing local index and remote index.");

            var filesToUpload = (from filePair in indexer.FileIndex where !s3indexer.HashedFiles.ContainsKey(filePair.Key) || !s3indexer.HashedFiles[filePair.Key].SequenceEqual(filePair.Value) select filePair.Key).ToList();
            var filesToDelete = (from filePair in s3indexer.HashedFiles where !indexer.FileIndex.ContainsKey(filePair.Key) select filePair.Key).ToList();

            foreach(var fileDelete in filesToDelete)
            {
                log.Debug("Deleting file "+fileDelete);
                s3.DeleteObject(new DeleteObjectRequest()
                                    {
                                        BucketName = Settings.Default.BucketName,
                                        Key = Settings.Default.FolderName + "/" + fileDelete
                                    });
            }

            foreach(var fileUpload in filesToUpload)
            {
                log.Debug("Uploading file "+fileUpload);
                s3.PutObject(new PutObjectRequest()
                                 {
                                     BucketName = Settings.Default.BucketName,
                                     Key = Settings.Default.FolderName + "/" + fileUpload,
                                     AutoCloseStream = true,
                                     InputStream = new FileStream("Files/" + fileUpload, FileMode.Open)
                                 });
            }

            log.Info("Re-indexing files...");

            using (MemoryStream stream = new MemoryStream())
            {
                Serializer.Serialize(stream, indexer.FileIndex);
                stream.Position = 0;
                s3.PutObject(new PutObjectRequest()
                {
                    BucketName = Settings.Default.BucketName,
                    Key = Settings.Default.FolderName + "/" + "index.mhash",
                    InputStream = stream
                });
            }

            log.Info("Done!");

            Console.Read();
        }
开发者ID:paralin,项目名称:S3FolderSync,代码行数:57,代码来源:Program.cs


示例15: S3

 /// <summary>
 /// Initializes a new instance of the S3
 /// </summary>
 /// <param name="client">Client</param>
 /// <param name="bucket">Bucket</param>
 /// <param name="relativePath">Relative Path</param>
 /// <param name="etag">ETag</param>
 public S3(AmazonS3 client, string bucket, string relativePath, string etag = null)
 {
     this.client = client;
     this.bucket = bucket;
     this.RelativePath = relativePath.Replace('\\', '/');
     if (!string.IsNullOrWhiteSpace(etag))
     {
         this.MD5 = System.Convert.ToBase64String(StringToByteArray(etag.Replace("\"", string.Empty)));
     }
 }
开发者ID:dineshkummarc,项目名称:A-Trak,代码行数:17,代码来源:S3.cs


示例16: CreateNewFolder

 public static string CreateNewFolder(AmazonS3 client, string foldername)
 {
     String S3_KEY = foldername;
     PutObjectRequest request = new PutObjectRequest();
     request.WithBucketName(BUCKET_NAME);
     request.WithKey(S3_KEY);
     request.WithContentBody("");
     client.PutObject(request);
     return S3_KEY;
 }
开发者ID:xescrp,项目名称:breinstormin,代码行数:10,代码来源:S3Engine.cs


示例17: S3Indexer

 /// <summary>
 /// Create an indexer given a bucket and folder.
 /// </summary>
 /// <param name="bucketName"></param>
 /// <param name="folderName"></param>
 public S3Indexer(string bucketName, string folderName, string downloadFolderName, AmazonS3 s3)
 {
     HashedFiles = new Dictionary<string, byte[]>();
     if(Directory.Exists(downloadFolderName)) Directory.Delete(downloadFolderName, true);
     Directory.CreateDirectory(downloadFolderName);
     downloadPath = downloadFolderName;
     this.s3 = s3;
     this.bucketName = bucketName;
     this.folderName = folderName;
 }
开发者ID:paralin,项目名称:S3FolderSync,代码行数:15,代码来源:S3Indexer.cs


示例18: CreateNewFileInFolder

 public static string CreateNewFileInFolder(AmazonS3 client, string foldername, string filepath)
 {
     String S3_KEY = foldername + "/" + System.IO.Path.GetFileName(filepath);
     PutObjectRequest request = new PutObjectRequest();
     request.WithBucketName(BUCKET_NAME);
     request.WithKey(S3_KEY);
     request.WithFilePath(filepath);
     //request.WithContentBody("This is body of S3 object.");
     client.PutObject(request);
     return S3_KEY;
 }
开发者ID:xescrp,项目名称:breinstormin,代码行数:11,代码来源:S3Engine.cs


示例19: GetObject

 private static void GetObject(AmazonS3 s3Client, string bucket, string key)
 {
     var getObjectRequest = new GetObjectRequest().WithBucketName(bucket).WithKey(key);
       using (var getObjectResponse = s3Client.GetObject(getObjectRequest))
       {
     var memoryStream = new MemoryStream();
     getObjectResponse.ResponseStream.CopyTo(memoryStream);
     var content = Encoding.Default.GetString(memoryStream.ToArray());
     Console.WriteLine(content);
       }
 }
开发者ID:nrazon,项目名称:S3Emulator,代码行数:11,代码来源:Program.cs


示例20: CopyFile

 public static void CopyFile(AmazonS3 s3Client, string sourcekey, string targetkey)
 {
     String destinationPath = targetkey;
     CopyObjectRequest request = new CopyObjectRequest()
     {
         SourceBucket = BUCKET_NAME,
         SourceKey = sourcekey,
         DestinationBucket = BUCKET_NAME,
         DestinationKey = targetkey
     };
     CopyObjectResponse response = s3Client.CopyObject(request);
 }
开发者ID:xescrp,项目名称:breinstormin,代码行数:12,代码来源:S3Engine.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# AmazonServiceCallback类代码示例发布时间:2022-05-24
下一篇:
C# AmazonDynamoDBCallback类代码示例发布时间: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