void IStorageProvider.UpdateBlobProperties(string containerName, string blobName, BlobProperties properties) { UpdateBlobProperties(containerName, blobName, properties); }
Task IStorageProvider.UpdateBlobPropertiesAsync(string containerName, string blobName, BlobProperties properties) { return(UpdateBlobPropertiesAsync(containerName, blobName, properties)); }
public void UpdateBlobProperties(string containerName, string blobName, BlobProperties properties) { AsyncHelpers.RunSync(() => UpdateBlobPropertiesAsync(containerName, blobName, properties)); }
public async Task UpdateBlobPropertiesAsync(string containerName, string blobName, BlobProperties properties) { var container = _blobClient.GetContainerReference(containerName); var blob = container.GetBlockBlobReference(blobName); try { await blob.FetchAttributesAsync(null, _requestOptions, _context).ConfigureAwait(false); blob.Properties.ContentType = properties.ContentType; await blob.SetPropertiesAsync(null, _requestOptions, _context).ConfigureAwait(false); var perms = await container.GetPermissionsAsync(null, _requestOptions, _context).ConfigureAwait(false); // Elevate container permissions if necessary. if (properties.Security == BlobSecurity.Public && perms.PublicAccess == BlobContainerPublicAccessType.Off) { await container.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }, null, _requestOptions, _context).ConfigureAwait(false); } } catch (Exception e) { if (e.IsAzureStorageException()) { throw e.Convert(); } throw; } }
public void SaveBlobStream(string containerName, string blobName, Stream source, BlobProperties properties = null) { AsyncHelpers.RunSync(() => SaveBlobStreamAsync(containerName, blobName, source, properties)); }
public async Task SaveBlobStreamAsync(string containerName, string blobName, Stream source, BlobProperties properties = null) { var container = _blobClient.GetContainerReference(containerName); var props = properties ?? BlobProperties.Empty; var security = props.Security == BlobSecurity.Public ? BlobContainerPublicAccessType.Blob : BlobContainerPublicAccessType.Off; try { var created = await container.CreateIfNotExistsAsync(security, _requestOptions, _context).ConfigureAwait(false); var blob = container.GetBlockBlobReference(blobName); blob.Properties.ContentType = props.ContentType; await blob.UploadFromStreamAsync(source, null, _requestOptions, _context).ConfigureAwait(false); // Check if container permission elevation is necessary if (!created) { var perms = await container.GetPermissionsAsync(null, _requestOptions, _context).ConfigureAwait(false); if (properties.Security == BlobSecurity.Public && perms.PublicAccess == BlobContainerPublicAccessType.Off) { await container.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = security }, null, _requestOptions, _context).ConfigureAwait(false); } } } catch (Exception e) { if (e.IsAzureStorageException()) { throw e.Convert(); } throw; } }
Task IStorageProvider.SaveBlobStreamAsync(string containerName, string blobName, Stream source, BlobProperties properties) { return(SaveBlobStreamAsync(containerName, blobName, source, properties)); }
public void UpdateBlobProperties(string containerName, string blobName, BlobProperties properties) { }
public Task SaveBlobStreamAsync(string containerName, string blobName, Stream source, BlobProperties properties = null) { return(Task.FromResult(0)); }
public void SaveBlobStream(string containerName, string blobName, Stream source, BlobProperties properties = null) { }
public Task UpdateBlobPropertiesAsync(string containerName, string blobName, BlobProperties properties) { return(Task.FromResult(0)); }