Ejemplo n.º 1
0
        public static void Initialize(TestContext a)
        {
            s3Client   = new AmazonS3Client(TestRegionEndpoint);
            bucketName = S3TestUtils.CreateBucket(s3Client);
            BucketAccelerateStatus bucketStatus = null;

            s3Client.PutBucketAccelerateConfiguration(new PutBucketAccelerateConfigurationRequest
            {
                BucketName = bucketName,
                AccelerateConfiguration = new AccelerateConfiguration
                {
                    Status = BucketAccelerateStatus.Enabled
                }
            });

            bucketStatus = s3Client.GetBucketAccelerateConfiguration(bucketName).Status;
            Assert.AreEqual(BucketAccelerateStatus.Enabled, bucketStatus);
        }
        public IRequest Marshall(PutBucketAccelerateConfigurationRequest putBucketAccelerateRequest)
        {
            //IL_0006: Unknown result type (might be due to invalid IL or missing references)
            //IL_000c: Expected O, but got Unknown
            //IL_0123: Unknown result type (might be due to invalid IL or missing references)
            IRequest val = new DefaultRequest(putBucketAccelerateRequest, "AmazonS3");

            val.set_HttpMethod("PUT");
            val.set_ResourcePath("/" + S3Transforms.ToStringValue(putBucketAccelerateRequest.BucketName));
            val.AddSubResource("accelerate");
            StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture);

            using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings
            {
                Encoding = Encoding.UTF8,
                OmitXmlDeclaration = true
            }))
            {
                AccelerateConfiguration accelerateConfiguration = putBucketAccelerateRequest.AccelerateConfiguration;
                if (accelerateConfiguration != null)
                {
                    xmlWriter.WriteStartElement("AccelerateConfiguration", "");
                    BucketAccelerateStatus status = accelerateConfiguration.Status;
                    if (accelerateConfiguration.IsSetBucketAccelerateStatus() && status != null)
                    {
                        xmlWriter.WriteElementString("Status", "", S3Transforms.ToXmlStringValue(ConstantClass.op_Implicit(accelerateConfiguration.Status)));
                    }
                    xmlWriter.WriteEndElement();
                }
            }
            try
            {
                string text = stringWriter.ToString();
                val.set_Content(Encoding.UTF8.GetBytes(text));
                val.get_Headers()["Content-Type"] = "application/xml";
                string value = AmazonS3Util.GenerateChecksumForContent(text, fBase64Encode: true);
                val.get_Headers()["Content-MD5"] = value;
                return(val);
            }
            catch (EncoderFallbackException ex)
            {
                throw new AmazonServiceException("Unable to marshall request to XML", (Exception)ex);
            }
        }
Ejemplo n.º 3
0
        public static AmazonS3Client GetInstance(string bucketName)
        {
            // Bucket Location
            RegionEndpoint regionEndPoint;

            using (IAmazonS3 s3Client = S3Client.GetInstance())
            {
                regionEndPoint = S3Client.GetBucketLocation(s3Client, bucketName);
            }

            // Transfer Acceleration
            using (IAmazonS3 s3Client = S3Client.GetInstance(regionEndPoint))
            {
                BucketAccelerateStatus accelerateStatus = s3Client.GetBucketAccelerateConfiguration(bucketName).Status;
                AmazonS3Config         amazonS3Config   = new AmazonS3Config()
                {
                    RegionEndpoint        = regionEndPoint,
                    UseAccelerateEndpoint = accelerateStatus == BucketAccelerateStatus.Enabled ? true : false,
                    ReadWriteTimeout      = Timeout
                };

                return(GetInstance(amazonS3Config));
            }
        }
Ejemplo n.º 4
0
        public static void Initialize(TestContext a)
        {
            s3Client   = new AmazonS3Client(TestRegionEndpoint);
            bucketName = S3TestUtils.CreateBucketWithWait(s3Client);
            BucketAccelerateStatus bucketStatus = null;

            s3Client.PutBucketAccelerateConfiguration(new PutBucketAccelerateConfigurationRequest
            {
                BucketName = bucketName,
                AccelerateConfiguration = new AccelerateConfiguration
                {
                    Status = BucketAccelerateStatus.Enabled
                }
            });

            var response = S3TestUtils.WaitForConsistency(() =>
            {
                var res = s3Client.GetBucketAccelerateConfiguration(bucketName);
                return(res.Status == BucketAccelerateStatus.Enabled ? res : null);
            });

            bucketStatus = response.Status;
            Assert.AreEqual(BucketAccelerateStatus.Enabled, bucketStatus);
        }