0
votes

I've the following scenario.... I am trying to download a file from a site with credentials and store it in the Azure Blob Storage.

For this I've created a app. Using the credentials I am able to access the file and download the file.

For this I've used WebClient.

NetworkCredential credentials = new NetworkCredential(userName, password);
CredentialCache cCache = new CredentialCache();
cCache.Add(new Uri(fileURL), "Basic", credentials);

WebClient wClient = new WebClient();
wClient.Credentials = cCache;
wClient.DownloadFile(fileUrl, fileName);

Using the above code I was able to download the file onto the machine on the cloud. But I want to store it in the Blob Storage container.

How do I do this.?

Thx

2

2 Answers

1
votes

WebClient.DownloadFile downloads the file to the path specified in the second parameter. In your case, I would like to suggest you to use the DownloadData method, which returns a byte array. Then you can use CloudBlob.UploadByteArray to upload the byte array to blob: http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.storageclient.cloudblob.uploadbytearray.

Best Regards,

Ming Xu.

0
votes

MSDN search "c# .net upload file to azure storage"

azure upload

Can you get you file into a stream?

BlobUploadStream

WebClientToStream