简体   繁体   中英

Azure download blob using url

I have created an Azure Cloud Service project on Visual Studio. I've been able to upload my files in the azure blob storage. What i need is, when click on a button, it will return me the URL of the uploaded blob such as http://127.0.0.1:10000/devstoreaccount1/conversions/filename.extension

In my View, i've done the following:

 <div class="table"> <table class="table table-responsive"> <thead> <tr> <th>File Name</th> <th>ConversionID</th> <th>Actual Format</th> <th>Status</th> <th>Download</th> </tr> </thead> @foreach (var item in Model) { <tr> <td>@item.FileName</td> <td>@item.ConversionID</td> <td>@item.Format</td> <td>@item.Status</td> <td> <a href="/Download.aspx?conversionID=@item.ConversionID"> <span class="DownloadListItem"> <b>Download<b> </span> </a> </tr> } </table> </div> 

My Download.aspx.cs:

    private ApplicationDbContext db = new ApplicationDbContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        string rawId = Request.QueryString["ConversionID"];
        int converionID;

        if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out converionID))
        {
          var v = db.Conversions.Where(a => a.ConversionID.Equals(converionID));  

            if (v != null)
            {
                //return ConversionURL
            }   
        }

        else
        {
            Debug.Fail("ERROR : We should never get to AddToCart.aspx without a ConversionID.");
            throw new Exception("ERROR : It is illegal to load AddToCart.aspx without setting a ConversionID.");
        }
    }

How can i return the ConversionURL in my code?

EDIT

When i upload a file, i upload the file and its content in Azure Blob Storage, but i also store on a SQL server database the ConversionID and ConversionURL of the uploaded file.

Once you upload your blob, you have the access to the Uri property of cloud blob . Save that after your upload to the database and return once you gets the ConversionId.

        blob.UploadFromFile(...);
        var blobUrl = blob.Uri;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM