Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobClient"/> class.
        /// </summary>
        /// <param name="cloudBlobClient">The CloudBlobClient instance.</param>
        public BlobClient(CloudBlobClient cloudBlobClient)
        {
            cloudBlobClient.ValidateNull();

            this._cloudBlobClient = cloudBlobClient;
            this.SetDefaultRetryIfNotExists(this._cloudBlobClient);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobContainer" /> class.
        /// </summary>
        /// <param name="containerName">Name of the container.</param>
        /// <param name="cloudBlobClient">The cloud blob client.</param>
        /// <param name="createIfNotExists">true to creates the container if it does not already exist; otherwise, false.</param>
        /// <param name="newContainerAccessType">Access type for the newly created container.</param>
        public BlobContainer(string containerName, CloudBlobClient cloudBlobClient, bool createIfNotExists, BlobContainerPublicAccessType newContainerAccessType)
        {
            containerName.ValidateContainerName();
            cloudBlobClient.ValidateNull();

            this._blobClient = new BlobClient(cloudBlobClient);

            this._cloudBlobContainer = this._blobClient.InnerCloudBlobClient.GetContainerReference(containerName);

            if (createIfNotExists)
            {
                if (this._cloudBlobContainer.CreateIfNotExists())
                {
                    var permissions = this._cloudBlobContainer.GetPermissions();
                    permissions.PublicAccess = newContainerAccessType;
                    this._cloudBlobContainer.SetPermissions(permissions);
                }
            }
        }