Reputation: 59
i'm trying to serialize an xml file and save it to azure. The serialization goes fine , and the code doesn't run into any problems when it runs the lines for the azure upload. But i can't tell if it's been uploaded or not. Any thoughts on how to retrieve a response from the server that it's been uploaded?
Below is my azure upload code :
CloudStorageAccount medcloudapp = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudBlobClient blobClient = medcloudapp.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
container.CreateIfNotExists();
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
using (var fileStream = System.IO.File.OpenRead(@"xmltransfer.xml"))
{
blockBlob.UploadFromStream(fileStream);
}
Upvotes: 2
Views: 781
Reputation: 136336
If you're not getting any errors in the following line of code:
blockBlob.UploadFromStream(fileStream);
That would mean your file is uploaded successfully.
Just for your peace of mind, you could try to fetch attributes of the blob and check it's size. It should be more than 0 bytes (assuming your XML file is more than 0 bytes in size). You would do something like:
blockBlob.FetchAttributes();
Assert.IsTrue(blockBlob.Properties.Length > 0);
Upvotes: 2