UploadFromStream() is storing 0Byte
5
I have tested it on my side. And that is true you need to set the stream position to 0 before uploading. Below is my sample code which works well.
static void Main(string[] args)
{
var stream = new MemoryStream();
var sw = new StreamWriter(stream);
sw.Write("adiojaihdhwjfoewjfioghauhfjowpf");
sw.Flush();
stream.Position = 0;
UploadfromstreamAsync(stream).Wait();
}
static async System.Threading.Tasks.Task UploadfromstreamAsync(MemoryStream stream)
{
CloudStorageAccount storageAccount = null;
CloudBlobContainer cloudBlobContainer = null;
string storageConnectionString = "connectionstring";
if (CloudStorageAccount.TryParse(storageConnectionString, out storageAccount))
{
CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();
cloudBlobContainer = cloudBlobClient.GetContainerReference("123");
CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference("TestBlobName2");
await cloudBlockBlob.UploadFromStreamAsync(stream);
}
}