-
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!
-
Re: Filestream Upload
Maybe it is a limit put by host?!.
-
Re: Filestream Upload
I tried several...and im sure it has limit up to 2gb. I tried 4 hosts too.
I've seen bytes count and then stop ... drop ... and again go up ... i mean memory just building up and going down ... but only when files are bigger than 1gb
The bigger the file the bigger the chance of not succeeding in uploading....
Never had problem with small files...up to 300mb.
EDIT:
i noticed, since im counting the bytes (converted later to mb) with
Code:
Worker.ReportProgress(11, count)
that after it reaches 900mb the count shows something like 39. or 52 ... and it hangs.
-
Re: Filestream Upload
so you said you played with the buffer right? this part
Code:
Dim buffer As Byte() = New Byte(1024)
also you are posting data, maybe as before the limit is set to 1gb, do you have access to the settings of the remote server?