aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2009-04-14 22:54:39 +0000
committerplegall <plg@piwigo.org>2009-04-14 22:54:39 +0000
commit3c27690c8761a5903e1697c4d1e365a1b0e4fa5c (patch)
tree65890bedc454f597cc00e96338b8ae9961edb643 /include/ws_functions.inc.php
parent77721e034bd53b3a3bb6cd2e0fd33d3564c638b2 (diff)
merge r3239 from branch 2.0 to trunk
bug 949 fixed: to avoid memory limit on server side, base64 encode chunks one by one on client side and base64 decode chunks one by one on server side. git-svn-id: http://piwigo.org/svn/trunk@3240 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php27
1 files changed, 18 insertions, 9 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 7c1d52580..422cfd176 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -923,9 +923,11 @@ function ws_images_add_chunk($params, &$service)
$params['position']
);
+ ws_logfile('[ws_images_add_chunk] data length : '.strlen($params['data']));
+
$bytes_written = file_put_contents(
$upload_dir.'/'.$filename,
- $params['data']
+ base64_decode($params['data'])
);
if (false === $bytes_written) {
@@ -958,17 +960,24 @@ function merge_chunks($output_filepath, $original_sum, $type)
}
sort($chunks);
+
+ ws_logfile('[merge_chunks] memory_get_usage before loading chunks: '.memory_get_usage());
- $string = null;
- foreach ($chunks as $chunk) {
- $string.= file_get_contents($chunk);
- unlink($chunk);
- }
- if (!file_put_contents($output_filepath, base64_decode($string)))
+ foreach ($chunks as $chunk)
{
- return new PwgError(500, 'error while merging chunks for '.$output_filepath);
+ $string = file_get_contents($chunk);
+
+ ws_logfile('[merge_chunks] memory_get_usage on chunk '.++$i.': '.memory_get_usage());
+
+ if (!file_put_contents($output_filepath, $string, FILE_APPEND))
+ {
+ return new PwgError(500, 'error while writting chunks for '.$output_filepath);
+ }
+
+ unlink($chunk);
}
-
+
+ ws_logfile('[merge_chunks] memory_get_usage after loading chunks: '.memory_get_usage());
}
function ws_images_add($params, &$service)