Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

mogupload: avoid slurping regular files into memory

This allows uploading of large files that do not fit into memory
again.  Data piped via stdin still uses a huge in-memory buffer
since server support for Content-Range/Transfer-Encoding:chunked
is inconsistent.
  • Loading branch information...
commit b14bc2ae879e6f2b9489e6e55129a5ef6d11e029 1 parent 601a1c5
Eric Wong authored
Showing with 2 additions and 6 deletions.
  1. +2 −6 mogupload
8 mogupload
@@ -44,10 +44,6 @@ A local file to upload. If '-', read file from STDIN instead.
Dormando E<lt>L<>E<gt>
-=head1 BUGS
-mogupload must buffer the upload in memory before transferring it. This makes it difficult to upload very large files. Future versions will lift this limitation.
=head1 LICENSE
Licensed for use and redistribution under the same terms as Perl itself.
@@ -70,7 +66,7 @@ my $filename = $c->{file};
die "Must specify a file to upload with --file" unless $filename;
my $fh;
-my $size = 0;
+my $size;
if ($filename eq '-') {
$fh = *STDIN;
} else {
@@ -79,7 +75,7 @@ if ($filename eq '-') {
open($fh, "< $filename") or die "Could not open " . $filename;
-my $mf = $mogc->new_file($c->{key}, $c->{class}, undef);
+my $mf = $mogc->new_file($c->{key}, $c->{class}, $size);
if ($mogc->errcode) {
die "Error opening MogileFS file: " . $mogc->errstr;
Please sign in to comment.
Something went wrong with that request. Please try again.