AlexGH AlexGH - 1 year ago 93
C# Question

Upload file into Blob Azure

I'm trying to upload files into blob Azure from an MVC app, I'm following this tutorial, and I'm stuck in this snippet:

using (var fileStream = System.IO.File.OpenRead(@"path\myfile"))

How to make
dynamic?? How to retrieve the real path of my file to put it in there? I accept any other suggestion too to upload to blob :)

Answer Source

HttpPostedFileBase will have the information you need. Specifically the InputStream property will give you the stream

public ActionResult PostFile(HttpPostedFileBase file, int NoteId)  
    // Your existing code for azure blob access
    CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob");
    // make sure to a null check on file parameter before accessing the InputStream

    using (var s = file.InputStream)
    // to do :Return something
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download