locked
Upload to Azure blob storage using file input RRS feed

  • Question

  • User-173651909 posted

    I'm trying to upload a file to Azure blob storage, and I'm struggling with the MS article here. Firstly I don't understand how you would set "path\myfile" in the code below (the file to upload).

    // Create or overwrite the "myblob" blob with contents from a local file.
    using (var fileStream = System.IO.File.OpenRead(@"path\myfile"))
    {
        blockBlob.UploadFromStream(fileStream);
    }

    Secondly, using a file browser control in the view how would you pass the value. It requires a string.

    Thanks in advance
    Adam

    Monday, February 15, 2016 2:16 PM

Answers

  • User-646145796 posted

    Hi,

    Adam-M

    I don't understand how you would set "path\myfile" in the code below (the file to upload).

    This is the path your file stored on your computer. Such as if you store the file in D:\, the path is D:\<your file>.

    If you use file browser control, I think we can get the file path via this control. So it is easy to upload to Azure blob. If your project can't get the file path because of some security reason, We can try to get the file stream, and then use blockBlob.UploadFromStream() to upload this stream.

    Best Regards,

    Jambor

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 16, 2016 2:42 AM