Hello there, I have a Program that shall upload Files. It actually works very well with smaller Movies, but when tried for example on a 300MB File it will just crash with an Error like
Out of memory during "large" request for 536875008 bytes, total sbrk() + is 7065600 bytes at /usr/local/lib/perl5/site_perl/5.8.9/HTTP/Reques +t/Common.pm line 160.
What id like to do now is to build a callback function, so that when I POST the file, it will basically read the File chunk by chunk. That way even if i upload a 1GB Movie, Memory used stays pretty much the same. I tried to implement it like this
my $filename = "largefile.avi"; open(FH,"<$filename"); my $upload_cb = sub { if ( sysread FH, my $buffer, 4096 ){ return $buffer; } else { close FH; return ''; } } # later in the Code, when uploading the File, calling it like this $vid_fields{field_uploadfile} = [ $upload_cb ] ; $vid_fields{field_private_share_entities} = ""; $resp = upload_step_two($action_url, \%vid_fields);
When running the Program, i get a
Can't open file CODE(0x821d6d4): No such file or directory at /usr/loc +al/lib/perl5/site_perl/5.8.9/LWP/UserAgent.pm line 401
Can someone give me a simple Example of POSTing a large File when using LWP::Useragent? Thanks a lot

In reply to POST'ing a large File with LWP::UserAgent by overrider

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.