Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-02-23 14:20:37

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

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

#2 2011-02-23 14:34:54

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

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

#3 2011-02-23 15:42:49

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

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

#4 2011-02-23 16:04:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

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

#5 2011-02-28 15:18:41

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

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

#6 2011-06-03 17:03:08

[Axel]
Member
From: Switzerland/Denmark
Registered: 2007-07-26
Posts: 65
Website

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

#7 2011-06-04 13:04:31

[Axel]
Member
From: Switzerland/Denmark
Registered: 2007-07-26
Posts: 65
Website

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

#8 2011-06-04 13:17:55

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

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

#9 2011-06-04 13:28:54

[Axel]
Member
From: Switzerland/Denmark
Registered: 2007-07-26
Posts: 65
Website

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

#10 2011-06-07 16:51:48

[Axel]
Member
From: Switzerland/Denmark
Registered: 2007-07-26
Posts: 65
Website

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

Board footer

Powered by FluxBB