From a Coded UI test method, what is the way to upload a captured image into Azure Storage and not saving in local drive?
To save a captured image into a local file, I am doing the following, it works fine:
BrowserWindow window = new BrowserWindow();
Image cml1 = window.CaptureImage();
cml1.Save(screenshotDir + screenshotDirClickMainLinks + "1" +
CMLelectAndNaturalGas + DateTime.Now.ToString(dateTime) + fileSuffix);
How to upload "cml1" into Azure Storage without saving it in a local drive? Do I convert cml1 one into a stream that can be input into an Azure storage object? This link looks to have some info, but it does not talk about Azure Storage. This link has "UploadFromStream" method for CloudBlockBlob, but no example is given.
For Azure Storage, I know how to create a container and upload a local file into that container. Here is the code segment:
if (CloudStorageAccount.TryParse(storageConnectionString, out storageAccount))
{
// Get the reference of the storage blob
CloudBlobClient client = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = client.GetContainerReference("testresult");
container.CreateIfNotExists();
CloudBlockBlob cloudBlockBlob = container.GetBlockBlobReference(localFileName);
cloudBlockBlob.UploadFromFile(sourceFile);
// Uploading second file
CloudBlobContainer container2 = client.GetContainerReference("testresult");
container2.CreateIfNotExists();
CloudBlockBlob cloudBlockBlob2 = container2.GetBlockBlobReference(localFileName2);
cloudBlockBlob2.UploadFromFile(sourceFile2);
}
How do I use "cml1" reference to upload the captured image into Azure Storage directly without saving it into a local folder first?
Thank you.