Sending a large file (wodWebServer / wodWebServer.NET)
by Simon, Wednesday, September 27, 2006, 07:01 (6632 days ago)
Hi there,
How can I send a large file?
I tried this without success:
User.Response.SendHeaders
User.Response.FileName = My_Large_File_Path
Will I need to chunk the data?
The files could be over 4 GB, potentially.
Simon
Re: Sending a large file
by wodDamir, Wednesday, September 27, 2006, 09:47 (6632 days ago) @ Simon
Hi Simon,
The Filename Property is used to specify the file in which response body should be stored. In your sample, if you open your page in your browser, you should see the content of the file you specified in the Filename Property.
However, if you specify a very big file, then loading such a page would take a long time.
If you want user to be able to download that page instead of viewing it's content in browser you could do something like this in RequestDone Event (VB6):
--------------------------------------------
User.Response.Headers.Add Content-Disposition , attachment; filename=your_file_filename
User.Response.FileName = path_to_your_file
--------------------------------------------
If you do this, then user who loads your page should be prompted with a save file dialog.
Hope i helped.
Regards,
Damba
Re: Sending a large file
by Simon, Wednesday, September 27, 2006, 10:42 (6632 days ago) @ wodDamir
Ok, I'm a little further now.
How do I know when sendChunk completes the send of the current packet?
Here is what I want to do:
I have a file that is slowly being generated.
I need to stream that file as it is being created.
For now, I'm having trouble streaming the file to the user's browser.
I am using sendChunk. After I send all the data, (4 MB) the browser only gets a 300 KB file.
I think the problem is sometimes the data is sendChunked too quickly to be processed by the webserver control and so its discarded.
I have set the following header info:
[code]
User.Response.Headers.Add Content-Type , binary/octet-stream
User.Response.Headers.Add Content-Length , 4325448
User.Response.Headers.Add Content-Disposition , filename= + fi _
+ ; size=4325448
[/code]
I then send the data little by little using a timer that goes off once every 250 ms:
user.Response.sendChunk (fdata)
I can't use User.UploadBytes because that includes the chunk header information.
Re: Sending a large file
by wodDamir, Wednesday, September 27, 2006, 14:53 (6632 days ago) @ Simon
Simon,
You could check if Chunk is sent in StateChange Event.
I.e. if the chunk was sent and there is more data to be sent, then your state would be changed to User is waiting to receive more data . In that case, just send the next chunk.
Hope this helps.
Regards,
Damba