Download Errors

Tagged:  

I've searched the forums and can't find this specific error. Kindly post a link if I'm blind :)

When attempting to download larger files (~30MB) I get instead a file with the following among the contents:

Sorry, fatal error happened
Allowed memory size of 33554432 bytes exhausted (tried to allocate 1048577 bytes)
{projectpier_install_dir}/environment/functions/files.php
/index.php?c=files&a=download_file&1319758462&id=54&active_project=15
pp086beta2
PHP version 5.2.10
Line 442

The files are stored on the filesystem (NOT DB). The server is a VPS with 1GB RAM.

I'm under the impression the current code base attempts to read the entire file into RAM to feed it out. Is there an existing patch for "chunking" the read and send of the file?

Cheers! :)

Figured it out :)

probably has to do with ob_start() being called somewhere earlier, so when the file contents are output, they're not sent directly to the browser, they're being sent to the buffer, which then expands to the size of the file (in this case being 34.1MB).

The solution:
in /environment/functions/files.php, around line 440/441 the original is

$handle = fopen($content, 'rb');
if ($handle === false) {
return false;
}
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
print $buffer;
flush();
}
return fclose($handle);

Change to:

$handle = fopen($content, 'rb');
if ($handle === false) {
return false;
}
ob_end_clean(); // edit
ob_start(); // edit
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
print $buffer;
ob_flush(); // edit
flush();
}
return fclose($handle);

Solved my problems! Is there a way to propose this as a code change for future releases?

Submitted via bugs http://www.projectpier.org/node/2838
Don't know if that's the best route? (Advice/Direction plz :)

error:
Call to undefined method FileRepository::getFilePath()

files:
/homepages/27/d374578089/htdocs/project/basecamp/application/plugins/files/controllers/FilesController.class.php

line:
420

if you need anything else please let me know ok..

Are you using the database or the filesystem to store files?
Your error is generated long before the actual download, I'm guessing that you switched from storing on the filesystem to storing in the database?

Perhaps this?
http://www.projectpier.org/node/2752

i figure it out.
i did exactly what is recomended on another treat.
right here http://www.projectpier.org/node/2752
and it work perfect.

thank you so much for getting back to me ok is working great.

Glad to have been able to help! :)