[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

send file from CGI

Detlef Reichl

11/4/2007 4:29:00 PM

Hi,

in a webapplication, a user can select from some options. Depending on
the selection some files are packed together in a zip file and get send
to the user. So far it works perfect, but the zip file is not recognized
from the browser and it displays the data as garbage.

The code that sends the data:


print @cgi.header("type" => "application/zip")
print @cgi.header("length" => File.size(zipfile).to_s)

file = File.new(zipfile, "r" )
while true
begin
data = file.sysread(65536)
rescue EOFError
break
else
@cgi.print data
end
end



Any suggestions?

Cheers
detlef


3 Answers

Daniel Völkerts

11/4/2007 4:35:00 PM

0

Detlef Reichl schrieb:

Hi Detlef,
> Any suggestions?
>
>
Wouldn't be easier to redirect the clients browser to the zip file? In
addition is "application/zip" the correct mime type?

HTH,

Daniel

Detlef Reichl

11/4/2007 4:40:00 PM

0

Am Montag, den 05.11.2007, 01:34 +0900 schrieb Daniel Völkerts:
> Detlef Reichl schrieb:
>
> Hi Detlef,
> > Any suggestions?
> >
> >
> Wouldn't be easier to redirect the clients browser to the zip file?

Hi Daniel

the zip file is not in the web root and also should not be

> In
> addition is "application/zip" the correct mime type?
>
afaik yes, but i also testet with other file types, with the same
result.

> HTH,
>
> Daniel


Marcin Raczkowski

11/7/2007 12:29:00 PM

0

Detlef Reichl wrote:
> Am Montag, den 05.11.2007, 01:34 +0900 schrieb Daniel Völkerts:
>> Detlef Reichl schrieb:
>>
>> Hi Detlef,
>>> Any suggestions?
>>>
>>>
>> Wouldn't be easier to redirect the clients browser to the zip file?
>
> Hi Daniel
>
> the zip file is not in the web root and also should not be
>
why not? securing data this way is kinda stupid.

>> In
>> addition is "application/zip" the correct mime type?
>>
> afaik yes, but i also testet with other file types, with the same
> result.
>
acording to http://www.iana.org/assignments/me... it's.

but some shity browsers (read IE wants file to have .zip extension even
if it's something like bleh.html?file=bloh.zip)