-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAzureBlobClient.cs
27 lines (24 loc) · 1.01 KB
/
AzureBlobClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
namespace AzureStorageRest
{
public class AzureBlobClient : AzureStorageClient
{
public AzureBlobClient(string storageAccount, HttpMessageHandler handler) : base(storageAccount, handler)
{
}
public AzureBlobClient(string storageAccount, string sharedAccessSignature) : base(storageAccount, sharedAccessSignature)
{
}
public async Task<string> Put(string container, string blob, Stream content)
{
var streamContent = new StreamContent(content);
// content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/atom+xml");
streamContent.Headers.Add("x-ms-blob-type", "BlockBlob");
var uri = string.Format(@"http://{0}.blob.core.windows.net/{1}/{2}{3}", StorageAccount, container, blob, SAS);
var resp = await Cli.PutAsync(uri, streamContent);
return await resp.Content.ReadAsStringAsync();
}
}
}