User1717218719 posted
I have the following code which uploads files to the local host then allows user to download the file. This code workes perfectly however what I now want to be able to do is link this to my azure storage account. if a file is uploaded to this website I want
it to auto upload to azure. How would I go about altering this code any help is appreciated. Thanks
Note my data source is a table in Microsoft sql.
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnAddNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
Response.Redirect("~/UploadFile.aspx")
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Select Case (e.Row.RowType)
Case DataControlRowType.DataRow
Dim myFileInfo As FileInfo = CType(e.Row.DataItem, FileInfo)
Select Case myFileInfo.ContentType.ToLower()
Case "image/pjpeg" ' .jpg files
Case "image/gif" ' .gif files
Case "application/msword" ' .doc files
Case "text/plain" ' .txt files
' Do nothing. When the row contains a viewable type,
' we want the View link to be enabled.
Case Else
' Find the View link and disable it.
Dim myLink As HyperLink = CType(e.Row.FindControl("lnkView"), HyperLink)
myLink.Enabled = False
End Select
End Select
End Sub
End Class
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Uploaded Files</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="odsFiles" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
<asp:BoundField DataField="OriginalName" HeaderText="OriginalName" SortExpression="OriginalName" />
<asp:BoundField DataField="ContentType" HeaderText="ContentType" SortExpression="ContentType" />
<asp:BoundField DataField="DateCreated" HeaderText="DateCreated" SortExpression="DateCreated" />
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/DownloadFile.aspx?Id={0}" HeaderText="Download" Text="Download" />
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<asp:HyperLink ID="lnkView" runat="server" NavigateUrl='<%# Eval("Id", "~/ViewFile.aspx?Id={0}") %>' Text="View"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<br />
<asp:Button ID="btnAddNew" runat="server" OnClick="btnAddNew_Click" Text="Add New File" /><br />
<br />
<br />
<asp:ObjectDataSource ID="odsFiles" runat="server" SelectMethod="GetList" TypeName="FileInfo" />
</div>
</form>
</body>
</html>