pmb88
pmb88

Reputation: 147

Cannot download zip file in FireFox

I am using the zip component to create a zip from memory and stream that file to download. It was working for a while, but in FireFox it won't let me download the file. Here is the code that I am using:


'  NewZip initializes the zip object.  It does not write
'  the file.  The "test.zip" file, in this case, will never be written.
success = zip.NewZip("lib-files.zip")
If (success <> True) Then
    'MsgBox(zip.LastErrorText)
    Exit Sub
End If
For Each oRow As Data.DataRow In oData.Tables(0).Rows
    If System.IO.File.Exists(Application("LibUploadedDocumentPath") & oRow("DocFileName").ToString) = True Then
        success = zip.AppendOneFileOrDir(Application("LibUploadedDocumentPath") & oRow("DocFileName").ToString, False)
        Dim entry As Chilkat.ZipEntry

        Dim fFile As FileInfo = New FileInfo(Application("LibUploadedDocumentPath") & oRow("DocFileName").ToString)
        Dim sNewFileName As String = oRow("DocName").ToString
        entry = zip.GetEntryByName(oRow("DocFileName").ToString)
        If (entry Is Nothing) Then
            MsgBox("Failed to find entry in .zip")
            Exit Sub
        End If
        'Dim sTestName As String = ""
        entry.FileName = sNewFileName & fFile.Extension.ToLower
    Else
        Response.Write("All the files are not found. Download aborted.")
        Exit Sub
    End If
Next
If (success <> True) Then
    'MsgBox(zip.LastErrorText)
    Exit Sub
End If
Dim Data As Byte()
Data = zip.WriteToMemory

Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Length", Data.Length.ToString())
Response.AddHeader("Content-Disposition",
               "attachment; filename=""" & zip.FileName & """")
Response.BinaryWrite(Data)
Response.Flush()
Response.End()

In FireFox it says, "the source file cannot be saved, because the source file could not be read". I've tried it in Chrome, and it allows me to download there. Not sure if its the component that's being used, or something else I need to add. Any thoughts?

Upvotes: 0

Views: 184

Answers (1)

Chilkat Software
Chilkat Software

Reputation: 1659

Maybe change the content type to "application/zip"?

Response.ContentType = "application/zip"

Upvotes: 1

Related Questions