Changeset 3239


Ignore:
Timestamp:
Apr 15, 2009, 12:49:04 AM (15 years ago)
Author:
plg
Message:

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.

Location:
branches/2.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/ws_functions.inc.php

    r3192 r3239  
    924924    );
    925925
     926  ws_logfile('[ws_images_add_chunk] data length : '.strlen($params['data']));
     927
    926928  $bytes_written = file_put_contents(
    927929    $upload_dir.'/'.$filename,
    928     $params['data']
     930    base64_decode($params['data'])
    929931    );
    930932
     
    959961
    960962  sort($chunks);
     963
     964  ws_logfile('[merge_chunks] memory_get_usage before loading chunks: '.memory_get_usage());
    961965 
    962   $string = null;
    963   foreach ($chunks as $chunk) {
    964     $string.= file_get_contents($chunk);
     966  foreach ($chunks as $chunk)
     967  {
     968    $string = file_get_contents($chunk);
     969   
     970    ws_logfile('[merge_chunks] memory_get_usage on chunk '.++$i.': '.memory_get_usage());
     971   
     972    if (!file_put_contents($output_filepath, $string, FILE_APPEND))
     973    {
     974      return new PwgError(500, 'error while writting chunks for '.$output_filepath);
     975    }
     976   
    965977    unlink($chunk);
    966978  }
    967   if (!file_put_contents($output_filepath, base64_decode($string)))
    968   {
    969     return new PwgError(500, 'error while merging chunks for '.$output_filepath);
    970   }
    971  
     979
     980  ws_logfile('[merge_chunks] memory_get_usage after loading chunks: '.memory_get_usage());
    972981}
    973982
  • branches/2.0/tools/piwigo_remote.pl

    r3192 r3239  
    256256    my %params = @_;
    257257
    258     my $content = encode_base64(read_file($params{filepath}));
     258    my $content = read_file($params{filepath});
    259259    my $content_length = length($content);
    260260    my $nb_chunks = ceil($content_length / $conf{chunk_size});
     
    274274            {
    275275                method => 'pwg.images.addChunk',
    276                 data => $chunk,
     276                data => encode_base64($chunk),
    277277                original_sum => $params{original_sum},
    278278                position => $chunk_id,
Note: See TracChangeset for help on using the changeset viewer.