當前位置: 首頁>>代碼示例>>C#>>正文


C# AmazonS3類代碼示例

本文整理匯總了C#中AmazonS3的典型用法代碼示例。如果您正苦於以下問題:C# AmazonS3類的具體用法?C# AmazonS3怎麽用?C# AmazonS3使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AmazonS3類屬於命名空間,在下文中一共展示了AmazonS3類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的AmazonS3類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。