473,320 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Sending Large File

PJ
I have the following code snippet to send a file stored as an image data
type from sql server:

Protected Sub StreamFile(ByVal fileItem As MyFile)
Dim offset As Integer
Dim buffer As Integer = 8192
Dim textPtr As System.Data.SqlTypes.SqlBinary =
MyFactory.GetFilePtr(fileItem.ID, FileScale.Original)

Response.Clear()
Response.Buffer = False
Response.ContentType = "application/octet-stream"
'should I set this???
'Response.AddHeader("Content-Length", fileItem.ByteCount.ToString())
Response.AddHeader("Content-Disposition", "attachment; filename=" +
fileItem.Name)
Response.Flush()

Dim size As Integer
Do
If offset + buffer > fileItem.ByteCount Then
size = fileItem.ByteCount - offset
Else
size = buffer
End If
Response.BinaryWrite(MyFactory.GetFileChunk(textPt r, offset,
fileItem.ByteCount))
Response.Flush()
offset += size
Loop Until offset >= fileItem.ByteCount
End Sub

This seems to be working, but I would like to make sure I am doing
everything as effeciently as possible. My understanding is that the
..Flush() method will send the current contents of the response to the
client. My understanding of the internals of the actual HTTP response(s) is
a bit weak. Is my loop creating sending a new response during each
iteration? If this is the case do the headers need to be set again or does
it simply use the current settings for the headers? Should I set the
"Content-Length" header? If so, should I set it's value to that of the
total byte count of the file or to the size of each flushed response? And
in general...is there a better way to do this?

TIA~ PJ
Nov 17 '05 #1
0 3913

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ian N | last post by:
Hi, I'm creating a site that posts orders to an email address when they're submitted, these orders need to be in the form of official invoices so i'm using HTML to format them. I already have...
1
by: Cindy Lee | last post by:
when I try to send a large web service message with a c# client, I get a read time out (it has nothing to do with timing out). It's not a sever problem, cus it works fine with a java client and...
11
by: Ron Vecchi | last post by:
I've used System.Web.Mail before but have never had the need to send attchemnets through it...until now. A client of mine would like a form on the website to allow a user to type up a message and...
4
by: Justin | last post by:
I have a fairly large piece of html, about 50 lines that I would like to send via an ASP.NET page I was wondering what would be the best and cleanest way to do this? Is there a way I can put the...
0
by: Buddy Ackerman | last post by:
I'm sending file to the client (see sample code below) but when I send a large file the user gets a document contains no data message. response.contenttype = "application/x-unknown" myheader =...
0
by: Buddy Ackerman | last post by:
I'm sending file to the client (see sample code below) but when I send a large file the user gets a document contains no data message. response.contenttype = "application/x-unknown" myheader =...
4
by: AtulSureka | last post by:
Hi, I have file of relatively larger size (4-5 Mbs) on client machine. I want to send this file to Server. For this I am using web services. Following is my perception, Please correct me if I...
3
by: יוני גולדברג | last post by:
Hi, I have two asp.net applications on different networks. One application has to call some operation/method on the other application and pass two large files as parameters: One file is huge xml...
1
by: Obaum1 | last post by:
Hello I am sending a file to a webservice after i transform him to byte And when i am sending a very large file(400 MB) i get an Exception of type 'System.OutOfMemoryException' was thrown. ...
0
by: jcatubay | last post by:
I have a function that returns a list more than 200000 objects and the object has 37 fields. I added the wcf as a web reference so i dont have to add any configuration item in my web apps config...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.