| <!-- HTML header for doxygen 1.9.1--> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| <meta name="generator" content="Doxygen 1.9.1"/> |
| <meta name="viewport" content="width=device-width, initial-scale=1"/> |
| <title>libapreq2-2.17: Apache2::Upload</title> |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="jquery.js"></script> |
| <script type="text/javascript" src="dynsections.js"></script> |
| <link href="customdoxygen.css" rel="stylesheet" type="text/css" /> |
| </head> |
| <body> |
| <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| <div id="titlearea"> |
| <table cellspacing="0" cellpadding="0" width="100%"> |
| <tbody> |
| <tr style="height: 56px;"> |
| <!-- |
| <td id="projectlogo"><img alt="Logo" src="feather.png"/></td> |
| --> |
| <!-- |
| <td id="projectalign" style="padding-left: 0.5em;"> |
| <div id="projectname">libapreq2 |
| < !--BEGIN PROJECT_NUMBER-- > <span id="projectnumber">2.17</span>< !--END PROJECT_NUMBER-- > |
| </div> |
| < !--BEGIN PROJECT_BRIEF-- ><div id="projectbrief"></div>< !--END PROJECT_BRIEF-- > |
| </td> |
| --> |
| <td> |
| <div id="page-header"> |
| <p class="menu"> |
| <a href="https://www.apache.org/">Apache Software Foundation</a> > |
| <a href="https://httpd.apache.org">HTTP Server Project</a> > |
| <a href="https://httpd.apache.org/apreq/">Request Library Subproject</a> |
| </p> |
| <p class="apache">Apache HTTP Server Request Library - 2.17</p> |
| <img alt="" src="feather.png" /> |
| </div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <!-- end header part --> |
| <!-- Generated by Doxygen 1.9.1 --> |
| <script type="text/javascript" src="menudata.js"></script> |
| <script type="text/javascript" src="menu.js"></script> |
| <script type="text/javascript"> |
| /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| $(function() { |
| initMenu('',false,false,'search.php','Search'); |
| }); |
| /* @license-end */</script> |
| <div id="main-nav"></div> |
| </div><!-- top --> |
| <div class="header"> |
| <div class="headertitle"> |
| <div class="title">Apache2::Upload<div class="ingroups"><a class="el" href="group__apreq__lang.html">Language Bindings</a> » <a class="el" href="group__apreq__xs.html">Perl</a></div></div> </div> |
| </div><!--header--> |
| <div class="contents"> |
| <div class="dynheader"> |
| Collaboration diagram for Apache2::Upload:</div> |
| <div class="dyncontent"> |
| <div class="center"><img src="group__apreq__xs__upload.png" border="0" usemap="#agroup____apreq____xs____upload" alt=""/></div> |
| <map name="agroup____apreq____xs____upload" id="agroup____apreq____xs____upload"> |
| <area shape="rect" title=" " alt="" coords="100,5,232,31"/> |
| <area shape="rect" href="group__apreq__xs.html" title="XS Modules." alt="" coords="5,5,52,31"/> |
| </map> |
| </div> |
| |
| |
| |
| |
| <ul id="index"> |
| <li><a href="#NAME">NAME</a></li> |
| <li><a href="#SYNOPSIS">SYNOPSIS</a></li> |
| <li><a href="#DESCRIPTION">DESCRIPTION</a></li> |
| <li><a href="#Apache2::Upload">Apache2::Upload</a> |
| <ul> |
| <li><a href="#name">name</a></li> |
| <li><a href="#filename">filename</a></li> |
| <li><a href="#fh">fh</a></li> |
| <li><a href="#io">io</a></li> |
| <li><a href="#bb">bb</a></li> |
| <li><a href="#size">size</a></li> |
| <li><a href="#info">info</a></li> |
| <li><a href="#type">type</a></li> |
| <li><a href="#link">link</a></li> |
| <li><a href="#slurp">slurp</a></li> |
| <li><a href="#tempname">tempname</a></li> |
| </ul> |
| </li> |
| <li><a href="#APR::Request::Brigade">APR::Request::Brigade</a> |
| <ul> |
| <li><a href="#TIEHANDLE">TIEHANDLE</a></li> |
| <li><a href="#READ">READ</a></li> |
| <li><a href="#READLINE">READLINE</a></li> |
| </ul> |
| </li> |
| <li><a href="#PORTING-from-1.X">PORTING from 1.X</a></li> |
| <li><a href="#SEE-ALSO">SEE ALSO</a></li> |
| <li><a href="#COPYRIGHT">COPYRIGHT</a></li> |
| </ul> |
| |
| <h1 id="NAME">NAME</h1> |
| |
| <p>Apache2::Upload - Methods for dealing with file uploads.</p> |
| |
| <h1 id="SYNOPSIS">SYNOPSIS</h1> |
| |
| <pre><code>use Apache2::Upload; |
| |
| $req = Apache2::Request->new($r); |
| $upload = $req->upload("foo"); |
| $size = $upload->size; |
| |
| # three methods to get at the upload's contents ... slurp, fh, io |
| |
| $upload->slurp($slurp_data); |
| |
| read $upload->fh, $fh_data, $size; |
| ok $slurp_data eq $fh_data; |
| |
| my $io = $upload->io; |
| print while <$io>;</code></pre> |
| |
| <h1 id="DESCRIPTION">DESCRIPTION</h1> |
| |
| <p>Apache2::Upload is a new module based on the original package included in Apache2::Request 1.X. Users requiring the upload API must now <code>use Apache2::Upload</code>, which adds the <code>upload</code> method to Apache2::Request. Apache2::Upload is largely backwards-compatible with the original 1.X API. See the <a href="#PORTING-from-1.X">"PORTING from 1.X"</a> section below for a list of known issues.</p> |
| |
| <p>This manpage documents the Apache2::Upload package.</p> |
| |
| <h1 id="Apache2::Upload">Apache2::Upload</h1> |
| |
| <h2 id="name">name</h2> |
| |
| <pre><code>$upload->name()</code></pre> |
| |
| <p>The name of the HTML form element which generated the upload.</p> |
| |
| <h2 id="filename">filename</h2> |
| |
| <pre><code>$upload->filename()</code></pre> |
| |
| <p>The (client-side) filename as submitted in the HTML form. Note: some agents will submit the file's full pathname, while others may submit just the basename.</p> |
| |
| <h2 id="fh">fh</h2> |
| |
| <pre><code>$upload->fh()</code></pre> |
| |
| <p>Creates filehandle reference to the upload's spooled tempfile, which contains the full contents of the upload.</p> |
| |
| <h2 id="io">io</h2> |
| |
| <pre><code>$upload->io()</code></pre> |
| |
| <p>Creates a tied IO handle. This method is a more efficient version of <code>fh</code>, but with <code>io</code> the handle ref returned is not seekable. It is tied to an APR::Request::Brigade object, so you may use the brigade API on the tied object if you want to manipulate the IO stream (beyond simply reading from it).</p> |
| |
| <p>The returned reference is actually an object which has <code>read</code> and <code>readline</code> methods available. However these methods are just syntactic sugar for the underlying <code>READ</code> and <code>READLINE</code> methods from APR::Request::Brigade.</p> |
| |
| <pre><code>$io = $upload->io; |
| print while $io->read($_); # equivalent to: tied(*$io)->READ($_)</code></pre> |
| |
| <p>See <a>READ</a> and <a>READLINE</a> below for additional notes on their usage.</p> |
| |
| <h2 id="bb">bb</h2> |
| |
| <pre><code>$upload->bb() |
| $upload->bb($set)</code></pre> |
| |
| <p>Get/set the APR::Brigade which represents the upload's contents.</p> |
| |
| <h2 id="size">size</h2> |
| |
| <pre><code>$upload->size()</code></pre> |
| |
| <p>Returns the size of the upload in bytes.</p> |
| |
| <h2 id="info">info</h2> |
| |
| <pre><code>$upload->info() |
| $upload->info($set)</code></pre> |
| |
| <p>Get/set the additional header information table for the uploaded file. Returns a hash reference tied to the <i>APR::Table</i> class. An optional <code>$table</code> argument can be passed to reassign the upload's internal (apr_table_t) info table to the one <code>$table</code> represents.</p> |
| |
| <pre><code>my $info = $upload->info; |
| while (my($hdr_name, $hdr_value) = each %$info) { |
| # ... |
| } |
| |
| # fetch upload's Content-Type header |
| my $type = $upload->info->{"Content-type"};</code></pre> |
| |
| <h2 id="type">type</h2> |
| |
| <pre><code>$upload->type()</code></pre> |
| |
| <p>Returns the MIME type of the given <i>Apache2::Upload</i> object.</p> |
| |
| <pre><code>my $type = $upload->type; |
| |
| #same as |
| my $content_type = $upload->info->{"Content-Type"}; |
| $content_type =~ s/;.*$//ms;</code></pre> |
| |
| <h2 id="link">link</h2> |
| |
| <pre><code>$upload->link()</code></pre> |
| |
| <p>To avoid recopying the upload's internal tempfile brigade on a *nix-like system, <i>link</i> will create a hard link to it:</p> |
| |
| <pre><code>my $upload = $req->upload('foo'); |
| $upload->link("/path/to/newfile") or |
| die sprintf "link from '%s' failed: $!", $upload->tempname;</code></pre> |
| |
| <p>Typically the new name must lie on the same device and partition as the brigade's tempfile. If this or any other reason prevents the OS from linking the files, <code>link()</code> will instead copy the temporary file to the specified location.</p> |
| |
| <h2 id="slurp">slurp</h2> |
| |
| <pre><code>$upload->slurp($contents)</code></pre> |
| |
| <p>Reads the full contents of a file upload into the scalar argument. The return value is the length of the file.</p> |
| |
| <pre><code>my $size = $upload->slurp($contents);</code></pre> |
| |
| <h2 id="tempname">tempname</h2> |
| |
| <pre><code>$upload->tempname()</code></pre> |
| |
| <p>Provides the name of the spool file.</p> |
| |
| <pre><code>my $tempname = $upload->tempname;</code></pre> |
| |
| <h1 id="APR::Request::Brigade">APR::Request::Brigade</h1> |
| |
| <p>This class is derived from APR::Brigade, providing additional methods for TIEHANDLE, READ and READLINE. To be memory efficient, these methods delete buckets from the brigade as soon as their data is actually read, so you cannot <code>seek</code> on handles tied to this class. Such handles have semantics similar to that of a read-only socket.</p> |
| |
| <h2 id="TIEHANDLE">TIEHANDLE</h2> |
| |
| <pre><code>APR::Request::Brigade->TIEHANDLE($bb)</code></pre> |
| |
| <p>Creates a copy of the bucket brigade represented by $bb, and blesses that copy into the APR::Request::Brigade class. This provides syntactic sugar for using perl's builtin <code>read</code>, <code>readline</code>, and <code><></code> operations on handles tied to this package:</p> |
| |
| <pre><code>use Symbol; |
| $fh = gensym; |
| tie *$fh, "APR::Request:Brigade", $bb; |
| print while <$fh>;</code></pre> |
| |
| <h2 id="READ">READ</h2> |
| |
| <pre><code>$bb->READ($contents) |
| $bb->READ($contents, $length) |
| $bb->READ($contents, $length, $offset)</code></pre> |
| |
| <p>Reads data from the brigade $bb into $contents. When omitted $length defaults to <code>-1</code>, which reads the first bucket into $contents. A positive $length will read in $length bytes, or the remainder of the brigade, whichever is greater. $offset represents the index in $context to read the new data.</p> |
| |
| <h2 id="READLINE">READLINE</h2> |
| |
| <pre><code>$bb->READLINE()</code></pre> |
| |
| <p>Returns the first line of data from the bride. Lines are terminated by linefeeds (the '\012' character), but we may eventually use <code>$/</code> instead.</p> |
| |
| <h1 id="PORTING-from-1.X">PORTING from 1.X</h1> |
| |
| <ul> |
| |
| <li><p><code>$upload->next()</code> is no longer available; please use the <code>APR::Request::Param::Table</code> API when iterating over upload entries.</p> |
| |
| </li> |
| <li><p><code>info($header_name)</code> is replaced by <code>info($set)</code>.</p> |
| |
| </li> |
| <li><p><code>type()</code> returns only the MIME-type portion of the Content-Type header.</p> |
| |
| </li> |
| </ul> |
| |
| <h1 id="SEE-ALSO">SEE ALSO</h1> |
| |
| <p><a>APR::Request::Param::Table</a>, <a>APR::Request::Error</a>, <a>Apache2::Request</a>, APR::Table(3)</p> |
| |
| <h1 id="COPYRIGHT">COPYRIGHT</h1> |
| |
| <pre><code>Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License.</code></pre> |
| |
| |
| </div><!-- contents --> |
| <!-- HTML footer for doxygen 1.9.1--> |
| <!-- start footer part --> |
| <hr class="footer"/> |
| <table class="footer"> |
| <td> |
| <address class="footer_left"><small> |
| Copyright © 2003-2022 <a href="https://www.apache.org">The Apache Software Foundation</a>.<br/> |
| See <a href="apreq_license.html">LICENSE</a>. |
| </small></address> |
| </td> |
| <td> |
| <address class="footer"><small> |
| Generated on Sat Sep 3 2022 17:23:06 for libapreq2 by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 |
| </small></address> |
| </td> |
| </table> |
| </body> |
| </html> |