Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Zip downloads through files form being mangled
Hi there,
I’ve got a problem on a site that is baffling me at the moment – I’ve uploaded a batch of zip files using the files admin tab, and have set up a files form to download them. But the downloaded zips are being corrupted somehow and I get an error when trying to unzip them.
If I set up a normal link to the file such as…
http://mysite.com/files/dirty-pictures.zip
…then it downloads and unzips totally fine.
If I use the Textpattern scheme (either as a hard coded link or through a files form) such as…
http://mysite.com/file_download/1/dirty-pictures.zip
…the zip is corrupted.
Anyone know why this could be happening? Something wrong in htaccess or apache config maybe? Using v4.3.0.
Last edited by philwareham (2011-02-23 14:21:21)
Offline
Re: Zip downloads through files form being mangled
philwareham wrote:
the zip is corrupted.
Although not necessarily a solution, could it be similar to this issue? Is your zip file large? What platform was it created on? Could it be a rogue BOM in the file? Does it help if you FTP the files up directly to the /files dir as Binary?
Would love to get to the bottom of this one.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Zip downloads through files form being mangled
Uploading the original Stuffit zip files via FTP still makes the same error when downloading through Textpattern, but if I download the file via FTP again it’s fine – so it’s definitely Textpattern based downloading where the problem is arising. Seems to be more of a problem with larger zip files – some small ones download and unzip fine.
I have been zipping the files with Stuffit v14 for Mac, just tried zipping with the inbuilt zip compressor in OSX and still the same problem.
Offline
Re: Zip downloads through files form being mangled
Honestly don’t know what to suggest. The file_download code hasn’t been touched since at least 4.0.8, if not before. And if it’s doing the same thing even if you upload via FTP then it can’t be the TXP upload process mangling the files.
So where does that leave us. External forces I guess. I don’t think it’s an OS thing (byte encoding of the file) but I can’t rule it out. It could be a plugin: are there any that might be linking into the file_download
callback, like smd_remote_file?
More likely you’re right that it’s .htaccess or some Apache module that’s getting in the way. What versions of various stuff are you running (PHP & Apache primarily)? Maybe posting your diagnostics might give someone cleverer than me a clue.
Hmmmm…
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Zip downloads through files form being mangled
Still have not figured this out, the server apache conf files are all set up OK and there is nothing in .htaccess apart from Textpattern’s default rules.
PHP is v5.2.9
Apache is v2.2.8
Also, there are no installed plugins on the site that I would expect to make file_download callbacks. But it is definitely as the links are passed through the file_download callback that the problem happens.
Offline
Re: Zip downloads through files form being mangled
I have the same problem on a site I’m working on.
I thought that application/octet-stream could be the troublemaker on the server side, but it isn’t as I found out.
I placed a .htaccess file in the files folder, to force download for directly linked files, and they download fine.
what else could we try to narrow the problem down?
**************************
<ifmodule mod_headers.c>
<filesMatch "\.(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</filesMatch>
</ifmodule>
**************************
Last edited by [Axel] (2011-06-03 18:14:05)
Greetz [Axel]
Offline
Re: Zip downloads through files form being mangled
found what caused my problem.
I had the jmd_html-0.4 plugin installed, removing heaps of slashes from the file while streaming.
Without it everything works fine.
Greetz [Axel]
Offline
Re: Zip downloads through files form being mangled
Ah, I use that plugin on my site as well – that’s the problem! Shame because I use that plugin to HTML5ify my pages.
Thanks Axel.
Offline
Re: Zip downloads through files form being mangled
I did the same.
It should not be to difficult to exclude the downloads to be filtered. I’ll have a look at it lateron
Greetz [Axel]
Offline
Re: Zip downloads through files form being mangled
I fixed the plugin, and are working on extending it to run on the admin site too if needed (example: HTML5 Admin themes)
When done I’ll put it to Textpattern Resources.
For the time being you can drop me a message and I’ll send you the code for the public side of TXP (does the job as the jmd_html-0.4 plugin did, without touching attachments).
Greetz [Axel]
Offline