コード例 #1
0
ファイル: S3TestUtils.cs プロジェクト: andyhopp/aws-sdk-net
        public static void WaitForBucket(IAmazonS3 client, string bucketName, int maxSeconds)
        {
            var sleeper = UtilityMethods.ListSleeper.Create();

            UtilityMethods.WaitUntilSuccess(() => {
                //Check if a bucket exists by trying to put an object in it
                var key = Guid.NewGuid().ToString() + "_existskey";

                var res = client.PutObject(new PutObjectRequest
                {
                    BucketName  = bucketName,
                    Key         = key,
                    ContentBody = "exists..."
                });

                try
                {
                    client.Delete(bucketName, key, null);
                }
                catch
                {
                    Console.WriteLine($"Eventual consistency error: failed to delete key {key} from bucket {bucketName}");
                }

                return(true);
            });

            //Double check the bucket still exists using the DoesBucketExistV2 method
            var exists = S3TestUtils.WaitForConsistency(() =>
            {
                return(AmazonS3Util.DoesS3BucketExistV2(client, bucketName) ? (bool?)true : null);
            });
        }
コード例 #2
0
ファイル: S3.cs プロジェクト: TcmExtensions/S3ECLProvider
        internal void RenameObject(String sourceKey, String destKey)
        {
            CopyObjectRequest request = new CopyObjectRequest()
            {
                CannedACL         = S3CannedACL.PublicRead,
                DestinationBucket = _bucketName,
                DestinationKey    = GetFullPrefix(destKey),
                MetadataDirective = S3MetadataDirective.COPY,
                SourceBucket      = _bucketName,
                SourceKey         = GetFullPrefix(sourceKey)
            };

            S3ItemData destination = GetObject(destKey);

            if (destination != null)
            {
                throw new Exception(String.Format("Destination object with key {0} already exists.", request.DestinationKey));
            }

            CopyObjectResponse response = _S3Client.CopyObject(request);

            if (response.HttpStatusCode != System.Net.HttpStatusCode.OK)
            {
                throw new Exception(String.Format("Failed to copy {0} to {1}", request.SourceKey, request.DestinationKey));
            }

            _S3Client.Delete(_bucketName, request.SourceKey, null);
        }
コード例 #3
0
ファイル: S3BucketVolume.cs プロジェクト: dannyboy997/FogFS
 public override void Delete(string path)
 {
     _s3Client.Delete(_bucketName, path, new Dictionary <string, object>());
 }