Пример #1
0
        public async Task <Uri> UploadFileAsync(string fileName, Stream content, BlobContainers containers, PublicAccessType accessType = PublicAccessType.None)
        {
            if (containers == BlobContainers.None)
            {
                throw new ArgumentException("Containers can not be NONE");
            }

            // TODO: get this from config
            var container = new BlobContainerClient("UseDevelopmentStorage=true", containers.ToString().ToLowerInvariant());
            await container.CreateIfNotExistsAsync(accessType);

            // Get a reference to a blob
            BlobClient blob = container.GetBlobClient(fileName);

            // Open the file and upload its data
            await blob.UploadAsync(content);

            // Verify we uploaded some content
            //BlobProperties properties = await blob.GetPropertiesAsync();
            return(blob.Uri);
        }
Пример #2
0
 public async Task UploadFileToStorage(BlobContainers containerName, string fileName, Stream fileStream)
 {
     BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName.ToString());
     // Get a reference to a blob
     BlobClient blobClient = containerClient.GetBlobClient(fileName);
     Response <BlobContentInfo> BlobUploadResponse = await blobClient.UploadAsync(fileStream, overwrite : true).ConfigureAwait(false);
 }