Ejemplo n.º 1
0
        public S3Store()
        {
            _S3Service = new S3Service()
            {
                AccessKeyID     = System.Environment.GetEnvironmentVariable("AMAZON_ACCESS_KEY_ID"),
                SecretAccessKey = System.Environment.GetEnvironmentVariable("AMAZON_SECRET_ACCESS_KEY")
            };

            if (_S3Service.QueryBucket(_bucketName) == BucketAccess.NoSuchBucket)
            {
                _S3Service.CreateBucket(_bucketName);
            }
        }
Ejemplo n.º 2
0
        private void CheckBucket(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Bucket name cannot be empty!");
            }
            if (Buckets.Contains(name))
            {
                return;
            }
            if (ConfigurationManager.AppSettings["S3CreateBucket"] != "true")
            {
                throw new ArgumentException(@"Dynamic bucket creation is not allowed. 
Please create bucket in advance or allow dynamic bucket creation with S3CreateBucket=true appConfig");
            }
            Service.CreateBucket(name);
        }
Ejemplo n.º 3
0
        public override bool CreateFolder()
        {
            using (var form = new NewBucketForm(bucketName))
            {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return(false);
                }
                if (RS.NewBucket.Equals(form.BucketName, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }

                S3Service.CreateBucket(form.BucketName, form.BucketLocation);
                return(true);
            }
        }
Ejemplo n.º 4
0
 public void CreateBucket(string bucketName, S3BucketLocation location)
 {
     client.CreateBucket(bucketName, (location ?? S3BucketLocation.Default).Code);
 }