Exemple #1
0
        public async Task <string> SaveBlobAsync(string container, string key, Stream bloblStream, bool anonymousAccess = false)
        {
            var blockBlob = await GetBlockBlobReferenceAsync(container, key, anonymousAccess, createIfNotExists : true);

            bloblStream.Position = 0;

            var mimeType = ContentTypesHelper.GetContentType(key);

            if (mimeType != null)
            {
                blockBlob.Properties.ContentType = mimeType;
            }

            await blockBlob.UploadFromStreamAsync(bloblStream, null, GetRequestOptions(), null);

            return(blockBlob.Uri.AbsoluteUri);
        }
Exemple #2
0
        public async Task SaveBlobAsync(string container, string key, byte[] blob, IReadOnlyDictionary <string, string> metadata)
        {
            var blockBlob = await GetBlockBlobReferenceAsync(container, key, createIfNotExists : true);

            var mimeType = ContentTypesHelper.GetContentType(key);

            if (mimeType != null)
            {
                blockBlob.Properties.ContentType = mimeType;
            }

            if (metadata != null)
            {
                foreach (var keyValuePair in metadata)
                {
                    blockBlob.Metadata[keyValuePair.Key] = keyValuePair.Value;
                }
            }

            await blockBlob.UploadFromByteArrayAsync(blob, 0, blob.Length, null, GetRequestOptions(), null);
        }