Direct upload from client in ASP.Net?

Last post 03-25-2008 4:55 PM by BarryR. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 02-25-2008 9:05 PM

    • dotmlj
    • Top 25 Contributor
    • Joined on 02-25-2008
    • Copenhagen, Denmark
    • Posts 15

    Direct upload from client in ASP.Net?

     Hi.

    I'm new to Nirvanix.

    Is it possible in ASP.Net to make a direct upload from the client (using a website) to Nirvanix, so we don't have to save the file on our own server and then upload it?

    Thanks

    Yours
    dotmlj

    Yours
    dotmlj
    Filed under: ,
  • 02-26-2008 9:08 PM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 630

    Re: Direct upload from client in ASP.Net?

    Yes, the c# snippet for HTTP upload has a compiled DLL that you can reference in VB.  This will give you a simple method that takes in a local filename and a remote file path and uploads the file.

    How to use the HTTP Library from VB Visual Studio 2005 

     

    1. Select any type of VB Project, I will use the empty project but you can use ASP.Net as well.

      Empty VB Project

    2. Add a Windows Form to the project. (or ASP.Net form)

      Add Windows Form

    3. Download the C# Snippet from http://developer.nirvanix.com/files/folders/csharpsnippets/entry580.aspx
    4. Extract the files from this zip and add a reference to the dll.

      Add reference

      browse http upload ref

    5. Add a web reference to the IMFS and Auth SOAP namespaces:

      add web reference

      Add http://services.nirvanix.com/ws/Authentication.asmx and change the Web reference name to: NVXAuth and click Add Reference.
      Add http://services.nirvanix.com/ws/IMFS.asmx and change the Web reference name to: NVXIMFS and click Add Reference.
    6. Drag a button to the form (Winform or ASP.Net web form) from the Toolbox:

      add button


    7. Double click the button and add the following code:

      Public Class Form1

          Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
              Dim Auth As New NVXAuth.Authentication
              Dim IMFS As New NVXIMFS.IMFS

              Dim Filename As String

              Filename = "c:\path\filetoupload.txt"

              Dim SessionToken As String
              SessionToken = Auth.Login("YOUR APP KEY", "YOUR USERNAME", "YOUR PASSWORD")


              Dim StorageNode As NVXIMFS.StorageNode
              StorageNode = IMFS.GetStorageNode(SessionToken, New IO.FileInfo(Filename).Length, Nothing)

              NirvanixSDK.HTTPUpload.UploadFileInChunks(StorageNode.UploadHost, StorageNode.UploadToken, "/RemotePath/", Filename, 4096 * 1024)
          End Sub
      End Class


      The above code will upload to whatever application / username you have defined in the login and place the file in the Filename variable in the directory /RemotePath/

      To run the application compile and click the button to upload the file.
    I hope this helps.  There are additional more advanced options for uploading to the server in the readme for the snippet as well.

     Regards,
        Barry R.
     

    IM Support (Feel free to add me)

    MSN: barryruffner@msn.com
    Gmail: barryruffner@gmail.com
  • 02-26-2008 10:47 PM In reply to

    • DatSure
    • Top 10 Contributor
    • Joined on 11-10-2007
    • Bettendorf, IA USA
    • Posts 31

    Re: Direct upload from client in ASP.Net?

    Barry:

    Really, you deserve a raise for the excellent work you do here!  Great job!

    - Joshua

    Sincerely,

    Joshua M. Andrews
    President
    DatSure, Inc.
    http://www.DatSure.com
  • 02-27-2008 7:11 PM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 630

    Re: Direct upload from client in ASP.Net?

     The best way to give me a raise is to use the system.  Feel free to upload as much as you like.  :)

     

    IM Support (Feel free to add me)

    MSN: barryruffner@msn.com
    Gmail: barryruffner@gmail.com
  • 03-12-2008 8:12 AM In reply to

    • dotmlj
    • Top 25 Contributor
    • Joined on 02-25-2008
    • Copenhagen, Denmark
    • Posts 15

    Re: Direct upload from client in ASP.Net?

    Thanks a lot :)

    Yours
    dotmlj
  • 03-25-2008 4:00 PM In reply to

    • dotmlj
    • Top 25 Contributor
    • Joined on 02-25-2008
    • Copenhagen, Denmark
    • Posts 15

    Re: Direct upload from client in ASP.Net?

    I finally got time to try this out and found that it doesn't solve my problem, as it uploads local files (that would have to be on the server).

    To explain my problem; I have some TextBox controls that has to be saved in the DB and a FileUpload control that has to be uploaded directly to Nirvanix.

    The (test) form looks like this:

    <strong>Upload file:</strong><br />
    File to upload: <asp:FileUpload ID="FileUpload1" runat="server" /><br />
    Description: <asp:TextBox ID="TextBoxFileDescription" runat="server" TextMode="MultiLine"></asp:TextBox><br />
    <asp:Button ID="ButtonUpload" runat="server" Text="Upload" />

    In the post back I can get and save the TextBoxFileDescription text but how do I upload the FileUpload1 file directly to Nirvanix, without having to upload it to our webserver first and without using eg. a Flash component?

    Yours
    dotmlj
  • 03-25-2008 4:55 PM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 630

    Re: Direct upload from client in ASP.Net?

    You can find a sample upload HTML page at http://node1.nirvanix.com/upload.htm this does the submit directly from the client to the Nirvanix servers.  You will need to generate a Upload Token and set which host you will upload to.

    Regards,
         Barry R.

    IM Support (Feel free to add me)

    MSN: barryruffner@msn.com
    Gmail: barryruffner@gmail.com
Page 1 of 1 (7 items)