goldsky / FileDownload-R

FileDownload snippet for MODX revolution
12 stars 7 forks source link

Files above 40mb not downloading #1

Closed djvern closed 13 years ago

djvern commented 13 years ago

Hi there,

I have an issue where files of size 40mb or more cannot be downloaded - the browser finds the file but downloads an empty version of it. I used to have Modx 0.9.6.1 running on the same server and used FileDownload 2.6 and had no problem with bigger files. I thought perhaps this was something to do with the hash - is there any way to disable the hash and have the file link directly to the URL of the file on the server as a work-around? I'm not concerned about the security that the hash adds - it would be nice to have an option to turn it off. If you can think of any other solution then let me know!

Many thanks, Dave

goldsky commented 13 years ago

I guess the problem was not with the hash, but with the memory. I believe PHP ran timeout when it tried to load all the 40MB to the header before completed.

Yes, the best way is by using the direct link, and it's easy to make that change. I'll let you know soon.

djvern commented 13 years ago

Ah yes that makes sense - I'm running Modx on a shared server and I think the PHP memory limit is set to 40mb... is it directly related to the hash then? So if there was a 256mb file I'd need 256mb memory? Yes if you could tell me how to use the direct link that would be great!

goldsky commented 13 years ago

I still can't find the easiest way to download a big file. Still having problem w/ memory.

If you want to use direct link, just put your file on your web accessible folder, and set the hyperlink to it.

anselmh commented 13 years ago

Can't you just set a hash to a small alias file that loads the direct link to the big file? Wouldn't that be an option?

djvern commented 13 years ago

I have resorted to using the FieLister plugin instead - the latest version has the ability to handle large files. The code is here - perhaps this can be adapted for FileDownload? https://github.com/crunch/FileLister/commit/c8e9250c8ca9019c5229d5d1412155bf1209eab0

goldsky commented 13 years ago

@djvern, that was exactly with what I was trying to do: https://github.com/goldsky/FileDownload-R/commit/929c6b110216d29fca3a054b8df34e6e076695a2 But still, it won't work for 60MB file.

@smooth-graphics, no, because if we use this script, that means we need this script to read the file first. That's where the memory's get sucked.

But another option is by using X-sendfile. https://gist.github.com/854168

I still try to find how the file hosters do their work.

djvern commented 13 years ago

@goldsky,

Re. the direct path link, is there any way to do this within the plugin? I have multiple client pages on my site and wanted to use the plugin to create the file links automatically (from files I've already uploaded via ftp) to save time. If I could disable the hash somehow it would solve my memory issue...

goldsky commented 13 years ago

how big are they?

djvern commented 13 years ago

anything up to 500mb. Can the file URL simply link to the real file path and not use the hash key (like the old FileDownload for Evo)?

goldsky commented 13 years ago

sure, I will make a little change. but it'll make the file web accessible, not out of the web root.

goldsky commented 13 years ago

Try to update to beta 4. I've added &directLink=1 property. Do not place the file under the core/ folder or out of the webroot. The file folder itself will be safe as long as you use the .htaccess that denies direct access to folders.

djvern commented 13 years ago

That's great - exactly what I needed, thanks a lot!

goldsky commented 13 years ago

yw