Ask a Question related to ASP.NET General, Design and Development.
-
PJ #1
Sending Large File
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
PJ Guest
-
How large an audio file can I add to a pdf?
How large an audio file can I add to a pdf? Thanks. Noe Kidder -
Sending a File
Can someone help me with this. I need to allow users to download a file, but only after logging in. So I can't just place the file out there on... -
Illustrator CS files with large linked files results in large file size
If I place a large linked Photoshop 7 file (.psd or.eps), say 36 MB, in Illustrator CS and save without embedding the file it takes ages to save and... -
Sending large data
Hi i am in a very peculiar situation, i am getting all the data from a pdf file and i am storing it in a dictionary object, i want to send it to a... -
PHP Warning: InterBase: Error while trying to open file File too large
Hello, I have this configuration: kernel 2.3.20, apache 1.3.27, with php 4.2.3 as apxs module with firebirdCS-1.0.3-64IO I have problems with...



Reply With Quote

