/usr/share/doc/libapache2-request-perl/html/group__apreq__xs__upload.html is in libapreq2-doc 2.13-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | <html>
<head>
<link rel="stylesheet" type="text/css" href="dox.css" />
<title>libapreq2-2.13: libapreq2: Apache2::Upload</title>
</head>
<body>
<div id="page-header">
<p class="menu">
<a href="http://www.apache.org/">Apache Software Foundation</a> > <a href="http://httpd.apache.org">HTTP Server Project</a> >
<a href="http://httpd.apache.org/apreq/">Request Library Subproject</a></p>
<p class="apache">Apache HTTP Server Request Library</p>
<img alt="" src="feather.gif" /></div>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>Apache2::Upload<br>
<small>
[<a class="el" href="group__apreq__xs.html">Perl</a>]</small>
</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
</table>
<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>
<ul>
<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></li>
<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><a href="#apr__request__brigade">APR::Request::Brigade</a></li>
<ul>
<li><a href="#tiehandle">TIEHANDLE</a></li>
<li><a href="#read">READ</a></li>
<li><a href="#readline">READLINE</a></li>
</ul>
<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>
<hr name="index" />
</div>
<!-- INDEX END -->
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Apache2::Upload - Methods for dealing with file uploads.</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
use Apache2::Upload;</pre>
<pre>
$req = Apache2::Request->new($r);
$upload = $req->upload("foo");
$size = $upload->size;</pre>
<pre>
# three methods to get at the upload's contents ... slurp, fh, io</pre>
<pre>
$upload->slurp($slurp_data);</pre>
<pre>
read $upload->fh, $fh_data, $size;
ok $slurp_data eq $fh_data;</pre>
<pre>
my $io = $upload->io;
print while <$io>;</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></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>
<p>
</p>
<hr />
<h1><a name="apache2__upload">Apache2::Upload</a></h1>
<p>
</p>
<h2><a name="name">name</a></h2>
<pre>
$upload->name()</pre>
<p>The name of the HTML form element which generated the upload.</p>
<p>
</p>
<h2><a name="filename">filename</a></h2>
<pre>
$upload->filename()</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>
<p>
</p>
<h2><a name="fh">fh</a></h2>
<pre>
$upload->fh()</pre>
<p>Creates filehandle reference to the upload's spooled tempfile,
which contains the full contents of the upload.</p>
<p>
</p>
<h2><a name="io">io</a></h2>
<pre>
$upload->io()</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>
$io = $upload->io;
print while $io->read($_); # equivalent to: tied(*$io)->READ($_)</pre>
<p>See <a href="#read">READ</a> and <a href="#readline">READLINE</a> below for additional notes
on their usage.</p>
<p>
</p>
<h2><a name="bb">bb</a></h2>
<pre>
$upload->bb()
$upload->bb($set)</pre>
<p>Get/set the APR::Brigade which represents the upload's contents.</p>
<p>
</p>
<h2><a name="size">size</a></h2>
<pre>
$upload->size()</pre>
<p>Returns the size of the upload in bytes.</p>
<p>
</p>
<h2><a name="info">info</a></h2>
<pre>
$upload->info()
$upload->info($set)</pre>
<p>Get/set the additional header information table for the
uploaded file.
Returns a hash reference tied to the <em>APR::Table</em> 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>
my $info = $upload->info;
while (my($hdr_name, $hdr_value) = each %$info) {
# ...
}</pre>
<pre>
# fetch upload's Content-Type header
my $type = $upload->info->{"Content-type"};</pre>
<p>
</p>
<h2><a name="type">type</a></h2>
<pre>
$upload->type()</pre>
<p>Returns the MIME type of the given <em>Apache2::Upload</em> object.</p>
<pre>
my $type = $upload->type;</pre>
<pre>
#same as
my $content_type = $upload->info->{"Content-Type"};
$content_type =~ s/;.*$//ms;</pre>
<p>
</p>
<h2><a name="link">link</a></h2>
<pre>
$upload->link()</pre>
<p>To avoid recopying the upload's internal tempfile brigade on a
*nix-like system, <em>link</em> will create a hard link to it:</p>
<pre>
my $upload = $req->upload('foo');
$upload->link("/path/to/newfile") or
die sprintf "link from '%s' failed: $!", $upload->tempname;</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>
<p>
</p>
<h2><a name="slurp">slurp</a></h2>
<pre>
$upload->slurp($contents)</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>
my $size = $upload->slurp($contents);</pre>
<p>
</p>
<h2><a name="tempname">tempname</a></h2>
<pre>
$upload->tempname()</pre>
<p>Provides the name of the spool file.</p>
<pre>
my $tempname = $upload->tempname;</pre>
<p>
</p>
<hr />
<h1><a name="apr__request__brigade">APR::Request::Brigade</a></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>
<p>
</p>
<h2><a name="tiehandle">TIEHANDLE</a></h2>
<pre>
APR::Request::Brigade->TIEHANDLE($bb)</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>
use Symbol;
$fh = gensym;
tie *$fh, "APR::Request:Brigade", $bb;
print while <$fh>;</pre>
<p>
</p>
<h2><a name="read">READ</a></h2>
<pre>
$bb->READ($contents)
$bb->READ($contents, $length)
$bb->READ($contents, $length, $offset)</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>
<p>
</p>
<h2><a name="readline">READLINE</a></h2>
<pre>
$bb->READLINE()</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>
<p>
</p>
<hr />
<h1><a name="porting_from_1_x">PORTING from 1.X</a></h1>
<ul>
<li>
<strong>
<a name="next" class="item"><code>$upload->next()</code> is no longer available; please use the
<code>APR::Request::Param::Table</code> API when iterating over upload entries.</a>
</strong>
<li>
<strong>
<a name="info" class="item"><code>info($header_name)</code> is replaced by <code>info($set)</code>.</a>
</strong>
<li>
<strong>
<a name="type" class="item"><code>type()</code> returns only the MIME-type portion of the Content-Type header.</a>
</strong>
</ul>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="group__apreq__xs__apr__request.html">the APR::Request::Param::Table manpage</a>, <a href="group__apreq__xs__apr__request__error.html">the APR::Request::Error manpage</a>, <a href="group__apreq__xs__request.html">the Apache2::Request manpage</a>,
APR::Table(3)</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<pre>
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</pre>
<pre>
<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a></pre>
<pre>
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.</pre>
</div>
<div id="footer">
<p class="apache">
Copyright © 2003-2006 <a href="http://www.apache.org">The Apache Software Foundation</a>.<br/>
See <a href="apreq_license.html">LICENSE</a>.</p>
<p class="menu">
<span style="color:#aaa">page generated by <a href="http://www.doxygen.org/"><code>doxygen</code></a>
version 1.5.6 on 25 Nov 2010</span>
</p>
</div>
</body>
</html>
|