0

I have developed ASP.NET application, and I used for uploading materials to my local pc following code:

   filename = Path.GetFileName(FileUpload1.FileName);
                FileUpload1.SaveAs(Server.MapPath("~/uploadfile/") + filename);
                Label1.Text = "Upload status: File uploaded!";

Now, I want this to upload on Azure and what I need is to change this code to suit uploading to my azure website. I have made storage there, but I don't know how should I code it. I have tried searching on google, but documentation is at least to say, horrible and very confusing. Any help is appreciated.

Thanks in advance.

  • 1
    Can you specify what documentation you read? I think the docs for how to use Blob Storage are well explained: http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/. Particularly, the section you'd be interested in is "How to: Upload a blob into a container" – Augusto Barreto Feb 21 '15 at 23:04
  • You would be better off using the file stream of the uploaded file rather than saving the file locally on your web server. The Blob storage client has methods that accept an input file stream. http://stackoverflow.com/questions/25889215/how-do-i-upload-a-file-to-azure-blob-storage-from-a-mvc-view – Simon W Feb 21 '15 at 23:25

1 Answers1

0

It isn't entirely clear to me what you are trying to do. Normally in ASP.Net applications you aren't actually trying to upload images from the local computer on which but actually want to have the user be able to use their browser to select an image from their computer. If that is what you are trying to do there are lots of samples out there. Here is a good one from the Mobile Services site, or here is another example - although it appears to use an older version of the storage client library so make sure you upgrade to the >= 4.0 version of the library if you take this app further than prototype. For a good overview of Blob storage look here.

If you are indeed simply trying to upload materials to / from your local PC to Blob Storage then take a look at AzCopy instead - it might be simpler.

Jason Hogg - MSFT
  • 1,369
  • 9
  • 10