bertly_the_coder wrote in post #1044365:
> I have a rails application that creates a couple of csv file, zips
> them up and sends them to the client as an attachment(for download)
> using this line:
>
> send_file t.path, :x_sendfile => true, :type => 'application/
> zip', :filename => "invited_friends_stats.zip"
> When I view the zipped file created on the server, I'm able to use it,
> however, when I download the file through the application, it
> uncompresses into a .zip.cpgz file, while in turn compresses into a
> zip file which compresses into a .zip.cpgz file, etc, etc.

What is .zip.cpgz?

> I then downloaded "The Unarchiver" app (on Mac OSX) and when I try and
> open the .zip file I get an error: "the contents cannot be extracted
> with this program"

I don't know why you would need this app. Mac OS X, at least any 
reasonably recent version, natively understands the .zip file format. 
These can typically be expanded by double-clicking them in Finder.

> Does anyone have any idea why this is happening? Encoding error, etc?
> Is there something I'm missing from the line above, or in my
> configuration that would fix this?

What did you use to compress the file server-side? My first guess is 
that the file is in some unsupported .zip format. It's also possible 
that the browser is trying to do some weird interpretation of the file. 
Are you sure your server is properly informing the browser of the 
correct content-type (mime-type)? I mean I see that you have specified 
that in your send_file, but did you actually look at the response in the 
browser to be sure? If you're using a WebKit based browser you can see 
that information using the Web Inspector. If using FireFox there's 
Firebug.

As far as I know Mac OS X should support standard zip (content-type: 
application/zip) or GNU ZIP (content-type: application/x-gzip), and 
probably some others as well. But, if you stick to one of those two you 
should be fine.

I would also compare the file that was compressed on the server with the 
file downloaded via the browser. If you run the two of them through a 
SHA1 you'll be able to tell if the file is arriving intact.

$ openssl dgst -sha1 MyZip.zip
SHA1(Untitled.rtf)= 17388cb38afe3d0f36a086458c96e334d6ec7e2c

Run something like that against the file on the server and the one 
downloaded through the browser. If the hashes match you know you're not 
getting corruption over the wire.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to