Generate XML file and upload to blob storage using x++.
using Microsoft.WindowsAzure.Storage;
Using Microsoft.WindowsAzure.Storage.Blob;
public class uploadXMLToBlobService extends SysOperationServiceBase
{
System.Byte[] reportBytes = new System.Byte[0]();
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
public void processOperation()
{
XmlDocument doc;
XmlElement mainNodeXml;
XmlElement oneChild;
XmlElement secondChild;
// #define.filename(@'D:\AnyNew.xml')
doc = XmlDocument::newBlank();
mainNodeXml = doc.createElement('HeaderXml');
doc.appendChild(mainNodeXml);
oneChild = doc.createElement('1child');
oneChild.setAttribute('Name','Value');
mainNodeXml.appendChild(oneChild);
secondChild = doc.createElement('2child');
secondChild.appendChild(doc.createTextNode('AccountName'));
oneChild.appendChild(secondChild);
//doc.save(#filename);
reportBytes = enc.GetBytes(doc.outerXml());
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(reportBytes);
CloudBlobDirectory cloudBlobDirectory;
CloudBlobClient cloudBlobClient;
CloudBlobContainer cloudBlobContainer;
CloudStorageAccount cloudStorageAccount;
cloudStorageAccount = CloudStorageAccount::Parse(invoiceParameters.StorageConnection);
cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
cloudBlobContainer = cloudBlobClient.GetContainerReference('Container name');
CloudBlockBlob CloudBlockBlob = cloudBlobContainer.GetBlockBlobReference('FilePath + uniqueFilename');
CloudBlockBlob.UploadFromStream(memoryStream, null, null, null);
}
}Keep Daxing!!
No comments:
Post a Comment