Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the <see cref="S3UploadStreamProvider" /> class with the specified configuration settings.
        /// </summary>
        /// <param name="settings">The <see cref="UploadStreamProviderElement" /> object that holds the configuration settings.</param>
        public S3UploadStreamProvider(UploadStreamProviderElement settings)
            : base(settings)
        {
            string accessKeyId = Settings.Parameters["accessKeyId"];
            string secretAccessKey = Settings.Parameters["secretAccessKey"];
            string bucketName = Settings.Parameters["bucketName"];
            bool useHttps;

            if (string.IsNullOrEmpty(accessKeyId))
                throw new Exception("accessKeyId must be specified for SlickUpload S3 provider");
            if (string.IsNullOrEmpty(secretAccessKey))
                throw new Exception("secretAccessKey must be specified for SlickUpload S3 provider");
            if (string.IsNullOrEmpty(bucketName))
                throw new Exception("bucketName must be specified for SlickUpload S3 provider");

            if (!bool.TryParse(Settings.Parameters["useHttps"], out useHttps))
                useHttps = true;

            _client = new S3BlobClient(accessKeyId, secretAccessKey, bucketName, useHttps);

            _objectNameMethod = TypeFactory.ParseEnum<ObjectNameMethod>(Settings.Parameters["objectNameMethod"], ObjectNameMethod.Client);

            _cacheControl = Settings.Parameters["cacheControl"];
            _contentDisposition = Settings.Parameters["contentDisposition"];
            _contentEncoding = Settings.Parameters["contentEncoding"];
            _cannedAcl = TypeFactory.ParseEnum<S3CannedAcl>(Settings.Parameters["cannedAcl"], S3CannedAcl.Private);
            _storageClass = TypeFactory.ParseEnum<S3StorageClass>(Settings.Parameters["storageClass"], S3StorageClass.Standard);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of the <see cref="S3UploadStreamProvider" /> class with the specified configuration settings.
        /// </summary>
        /// <param name="settings">The <see cref="UploadStreamProviderElement" /> object that holds the configuration settings.</param>
        public S3UploadStreamProvider(UploadStreamProviderElement settings)
            : base(settings)
        {
            string accessKeyId     = Settings.Parameters["accessKeyId"];
            string secretAccessKey = Settings.Parameters["secretAccessKey"];
            string bucketName      = Settings.Parameters["bucketName"];
            bool   useHttps;

            if (string.IsNullOrEmpty(accessKeyId))
            {
                throw new Exception("accessKeyId must be specified for SlickUpload S3 provider");
            }
            if (string.IsNullOrEmpty(secretAccessKey))
            {
                throw new Exception("secretAccessKey must be specified for SlickUpload S3 provider");
            }
            if (string.IsNullOrEmpty(bucketName))
            {
                throw new Exception("bucketName must be specified for SlickUpload S3 provider");
            }

            if (!bool.TryParse(Settings.Parameters["useHttps"], out useHttps))
            {
                useHttps = true;
            }

            _client = new S3BlobClient(accessKeyId, secretAccessKey, bucketName, useHttps);

            _objectNameMethod = TypeFactory.ParseEnum <ObjectNameMethod>(Settings.Parameters["objectNameMethod"], ObjectNameMethod.Client);

            _cacheControl       = Settings.Parameters["cacheControl"];
            _contentDisposition = Settings.Parameters["contentDisposition"];
            _contentEncoding    = Settings.Parameters["contentEncoding"];
            _cannedAcl          = TypeFactory.ParseEnum <S3CannedAcl>(Settings.Parameters["cannedAcl"], S3CannedAcl.Private);
            _storageClass       = TypeFactory.ParseEnum <S3StorageClass>(Settings.Parameters["storageClass"], S3StorageClass.Standard);
        }