2016-05-22 54 views
-1

我在Visual Studio上创建了Azure Cloud Service项目。我已经能够在azure blob存储中上传我的文件。我需要的是,当点击一个按钮,它会返回我上传的斑点这样的URL为http://127.0.0.1:10000/devstoreaccount1/conversions/filename.extension使用url的Azure下载blob

在我看来,我已经做了以下内容:

<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>

我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."); 
     } 
    } 

我怎样才能返回ConversionURL在我的代码?

编辑

当我上传一个文件,我上传的文件及其在Azure的Blob存储的内容,但我也存储在SQL Server数据库中上传文件的转换编号和ConversionURL上。

+1

您需要告诉我们您的conversionID与您上传的文件的关系。 –

+0

刚刚编辑我的帖子! – Huby03

回答

1

一旦你上传你的blob,你可以访问Uri property of cloud blob。在上传到数据库之后保存该信息,并在获取ConversionId后返回。

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