Esempio n. 1
0
    private static BlobContainerSasPermissions ConvertPermissions(ContainerPermission permission)
    {
        BlobContainerSasPermissions blobPermissions = 0;

        if (permission.HasFlag(ContainerPermission.Read))
        {
            blobPermissions |= BlobContainerSasPermissions.Read;
        }

        if (permission.HasFlag(ContainerPermission.Write))
        {
            blobPermissions |= BlobContainerSasPermissions.Write;
        }

        if (permission.HasFlag(ContainerPermission.Delete))
        {
            blobPermissions |= BlobContainerSasPermissions.Delete;
        }

        if (permission.HasFlag(ContainerPermission.List))
        {
            blobPermissions |= BlobContainerSasPermissions.List;
        }

        return(blobPermissions);
    }
Esempio n. 2
0
        public async Task SetPermissionAsync(ContainerPermission permission)
        {
            BlobContainerPublicAccessType accessType = permission.HasFlag(ContainerPermission.Public) ?
                                                       BlobContainerPublicAccessType.Blob :
                                                       BlobContainerPublicAccessType.Off;

            try {
                await this._blobContainer
                .SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = accessType })
                .ConfigureAwait(false);
            }
            catch (Exception e) {
                throw new StorageException(StorageExceptionReason.StorageOperationFailed, "Unable to set permissions for the storage.", e);
            }
        }
        public async Task SetPermissionAsync(ContainerPermission permission)
        {
            BlobContainerPublicAccessType accessType = permission.HasFlag(ContainerPermission.Public) ?
                BlobContainerPublicAccessType.Blob :
                BlobContainerPublicAccessType.Off;

            try {
                await this._blobContainer
                    .SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = accessType })
                    .ConfigureAwait(false);
            }
            catch (Exception e) {
                throw new StorageException(StorageExceptionReason.StorageOperationFailed, "Unable to set permissions for the storage.", e);
            }
        }