Reputation: 801
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="/[email protected]">
<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.
Upvotes: 0
Views: 2915
Reputation: 4062
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;
Upvotes: 2