472,975 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

http download corrupting zip file

I have an http download that streams a zip file to client, after download I
am getting "Error [file name] start of central directory not found; Zip file
corrupt. Possible casue: file transfer error."

Ring any bells? Here's the asp code, thanks in advance!!

Derrick

...
Response.ContentType = "application/zip"
Response.AddHeader "Content-Disposition", "attachment; filename=" &
downloadFile

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.End
Jul 21 '05 #1
3 8949
more info, in particular, I can reproduce this, the code below generates a
different size file on the client, the download file on the server is 63.7
MB (66,848,355 bytes), when I download it grows to 63.7 MB (66,851,533
bytes), consistently. ??

Thanks in advance for any help!

Derrick

"Derrick" <de*********@excite.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I have an http download that streams a zip file to client, after download I am getting "Error [file name] start of central directory not found; Zip file corrupt. Possible casue: file transfer error."

Ring any bells? Here's the asp code, thanks in advance!!

Derrick

...
Response.ContentType = "application/zip"
Response.AddHeader "Content-Disposition", "attachment; filename=" & downloadFile

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.End

Jul 21 '05 #2
I'm doing similar with similar sized files...my code is:

MyFileStream = New FileStream(pathspec & filespec, FileMode.Open)
FileSize = MyFileStream.Length

Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()

Response.BufferOutput = True

Response.ContentType = "application/asp-unknown"

Response.AddHeader("content-disposition", "attachment; filename=" &
filespec)

Response.BinaryWrite(Buffer)

Response.Flush()
Response.End()

Jeff

"Derrick" <de*********@excite.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I have an http download that streams a zip file to client, after download I am getting "Error [file name] start of central directory not found; Zip file corrupt. Possible casue: file transfer error."

Ring any bells? Here's the asp code, thanks in advance!!

Derrick

...
Response.ContentType = "application/zip"
Response.AddHeader "Content-Disposition", "attachment; filename=" & downloadFile

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.End

Jul 21 '05 #3
Jeff, thanks, I looked at yours which appears to be asp.net, rewrote mine a
bit, this modified code downloads the file with the correct size..
interesting, I'm guessing it's the clear and flush around the binary write..

'Set the content type to the specific type that you are sending.
Set objFilesystem =
Server.CreateObject("Scripting.FileSystemObject")
Set objFilestream = objFilesystem.GetFile(downloadPath)
intFilelength = objFilestream.size

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.Clear
Response.ContentType = "octet-stream" '"application/zip"
Response.AddHeader "Content-Disposition", "attachment; filename=" &
downloadFile
Response.AddHeader "Content-Length", intFilelength
Response.BinaryWrite objStream.Read(intFileLength)
Response.Flush
Response.End

objStream.Close
Set objStream = Nothing
"Jeff Dillon" <je**@removeemergencyreporting.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm doing similar with similar sized files...my code is:

MyFileStream = New FileStream(pathspec & filespec, FileMode.Open)
FileSize = MyFileStream.Length

Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()

Response.BufferOutput = True

Response.ContentType = "application/asp-unknown"

Response.AddHeader("content-disposition", "attachment; filename=" &
filespec)

Response.BinaryWrite(Buffer)

Response.Flush()
Response.End()

Jeff

"Derrick" <de*********@excite.com> wrote in message
news:Oh**************@TK2MSFTNGP09.phx.gbl...
I have an http download that streams a zip file to client, after
download I
am getting "Error [file name] start of central directory not found; Zip file
corrupt. Possible casue: file transfer error."

Ring any bells? Here's the asp code, thanks in advance!!

Derrick

...
Response.ContentType = "application/zip"
Response.AddHeader "Content-Disposition", "attachment;

filename=" &
downloadFile

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile downloadPath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.End


Jul 22 '05 #4

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

Similar topics

1
by: Silvia | last post by:
I have this code in web.config file <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="dllredirect"/> <codeBase...
2
by: Derrick | last post by:
Anyone been able to get a multi file HTTP download working with ASP? I have a single file download working fine with the usual setting the content type, file name, stream the file from...
0
by: Chuck Anderson | last post by:
I am writing a Php script to run on my home PC (Windows) that downloads an Apache access log file and inserts new entries into a database.. The only way I can access these log files is through a...
13
by: PamelaDV | last post by:
I have a database split for back end and front end and my back end (my data) has been corrupting like crazy lately. Today we have compacted and repaired like 4 times within an hour. The database...
0
by: Owen Jenkins | last post by:
I've been using Dev's fantastic InetTransferLib to upload and download files via ftp. Now I'm using the http procedures to have my application download zip files from my website. Although the...
1
by: Owen Jenkins | last post by:
Reposting this message from last week since I have not had a reply so far. Hopefully someone will have an idea? --- I've been using Dev's fantastic InetTransferLib to upload and download files...
2
by: Dmitry Duginov | last post by:
I wrote HTTP module and configured it to fire with every request to my application. In IIS6 aspnet_isapi.dll mapped as Application Extension, web.config contains the following: <system.web> ...
4
by: Gary Wessle | last post by:
Hi please look at the code below, the problem I have is that line 37 does not print out into the file as expected. however if I move it to be immediately after line 16 it prints fine into the...
7
by: LogicMechanic | last post by:
I have an SMTP listener that accepts incoming connections and routes the message to a folder using FileStream. I have to add x-sender: email@address.com and x-receiver: email@address.com to the first...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.