Results 1 to 4 of 4

Thread: Filestream Upload

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Unhappy Filestream Upload

    Hi guys,

    I'm stuck with uploading obtaining a Stream. I'm putting the file with Filestream and it works great when files are smaller than 1gb.

    I tried changing buffer size ... but no luck. If you could give me an advice, that would be great.

    The crucial code is here. I did leave behind other parts of the code that are not essential and it would just make this part of the code harder to read.


    Code:
    Dim wr As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
    ' NON LATIN char - >  "multipart/form-data; charset=UTF-8; boundary=" + boundary;
    wr.ContentType = Convert.ToString("multipart/form-data; boundary=") & boundary
    wr.Method = "POST"
    wr.KeepAlive = True
    wr.Credentials = System.Net.CredentialCache.DefaultCredentials
    
    
    
     Dim rs As Stream = wr.GetRequestStream()
     Dim FS As New FileStream(File_Path, FileMode.Open, FileAccess.Read)
    
    Dim buffer As Byte() = New Byte(1024) {} 
    Dim bytesRead As Integer = 0
    
    Dim count As Integer = 0
    While (InlineAssignHelper(bytesRead, FS.Read(buffer, 0, buffer.Length))) <> 0
                  rs.Write(buffer, 0, bytesRead)
                  count += bytesRead
                  Worker.ReportProgress(11, count)
    End While
    
    FS.Close()

    Cheers!
    Last edited by batori; May 14th, 2014 at 02:36 PM.
    Thanks for helping me out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width