apache2::upload.3

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 3 代码 · 共 391 行

3
391
字号
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings.  \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote.  \*(C+ will.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\.    ds -- \(*W-.    ds PI pi.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch.    ds L" "".    ds R" "".    ds C` "".    ds C' ""'br\}.el\{\.    ds -- \|\(em\|.    ds PI \(*p.    ds L" ``.    ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el       .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD.  Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\.    de IX.    tm Index:\\$1\t\\n%\t"\\$2"...    nr % 0.    rr F.\}.el \{\.    de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear.  Run.  Save yourself.  No user-serviceable parts..    \" fudge factors for nroff and troff.if n \{\.    ds #H 0.    ds #V .8m.    ds #F .3m.    ds #[ \f1.    ds #] \fP.\}.if t \{\.    ds #H ((1u-(\\\\n(.fu%2u))*.13m).    ds #V .6m.    ds #F 0.    ds #[ \&.    ds #] \&.\}.    \" simple accents for nroff and troff.if n \{\.    ds ' \&.    ds ` \&.    ds ^ \&.    ds , \&.    ds ~ ~.    ds /.\}.if t \{\.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u".    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}.    \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E.    \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'.    \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\.    ds : e.    ds 8 ss.    ds o a.    ds d- d\h'-1'\(ga.    ds D- D\h'-1'\(hy.    ds th \o'bp'.    ds Th \o'LP'.    ds ae ae.    ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "Apache2::Upload 3".TH Apache2::Upload 3 "2006-08-09" "perl v5.10.0" "User Contributed Perl Documentation".\" For nroff, turn off justification.  Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"Apache2::Upload \- Methods for dealing with file uploads..SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 1\&    use Apache2::Upload;\&\&    $req = Apache2::Request\->new($r);\&    $upload = $req\->upload("foo");\&    $size = $upload\->size;\&\&    # three methods to get at the upload\*(Aqs 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>;.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"Apache2::Upload is a new module based on the original package includedin Apache2::Request 1.X.  Users requiring the upload \s-1API\s0 must now\&\f(CW\*(C`use Apache2::Upload\*(C'\fR, which adds the \f(CW\*(C`upload\*(C'\fR method to Apache2::Request.Apache2::Upload is largely backwards-compatible with the original 1.X \s-1API\s0.See the \*(L"\s-1PORTING\s0 from 1.X\*(R" section below for a list of known issues..PPThis manpage documents the Apache2::Upload package..SH "Apache2::Upload".IX Header "Apache2::Upload".Sh "name".IX Subsection "name".Vb 1\&    $upload\->name().Ve.PPThe name of the \s-1HTML\s0 form element which generated the upload..Sh "filename".IX Subsection "filename".Vb 1\&    $upload\->filename().Ve.PPThe (client-side) filename as submitted in the \s-1HTML\s0 form.  Note:some agents will submit the file's full pathname, while othersmay submit just the basename..Sh "fh".IX Subsection "fh".Vb 1\&    $upload\->fh().Ve.PPCreates filehandle reference to the upload's spooled tempfile,which contains the full contents of the upload..Sh "io".IX Subsection "io".Vb 1\&    $upload\->io().Ve.PPCreates a tied \s-1IO\s0 handle.  This method is a more efficient versionof \f(CW\*(C`fh\*(C'\fR, but with \f(CW\*(C`io\*(C'\fR the handle ref returned is not seekable.It is tied to an APR::Request::Brigade object, so you may use thebrigade \s-1API\s0 on the tied object if you want to manipulate the \s-1IO\s0 stream(beyond simply reading from it)..PPThe returned reference is actually an object which has \f(CW\*(C`read\*(C'\fR and\&\f(CW\*(C`readline\*(C'\fR methods available.  However these methods are justsyntactic sugar for the underlying \f(CW\*(C`READ\*(C'\fR and \f(CW\*(C`READLINE\*(C'\fR methods fromAPR::Request::Brigade..PP.Vb 2\&    $io = $upload\->io;\&    print while $io\->read($_); # equivalent to: tied(*$io)\->READ($_).Ve.PPSee \s-1READ\s0 and \s-1READLINE\s0 below for additional noteson their usage..Sh "bb".IX Subsection "bb".Vb 2\&    $upload\->bb()\&    $upload\->bb($set).Ve.PPGet/set the APR::Brigade which represents the upload's contents..Sh "size".IX Subsection "size".Vb 1\&    $upload\->size().Ve.PPReturns the size of the upload in bytes..Sh "info".IX Subsection "info".Vb 2\&    $upload\->info()\&    $upload\->info($set).Ve.PPGet/set the additional header information table for theuploaded file.Returns a hash reference tied to the \fIAPR::Table\fR class.An optional \f(CW$table\fR argument can be passed to reassignthe upload's internal (apr_table_t) info table to the one\&\f(CW$table\fR represents..PP.Vb 4\&    my $info = $upload\->info;\&    while (my($hdr_name, $hdr_value) = each %$info) {\&        # ...\&    }\&\&    # fetch upload\*(Aqs Content\-Type header\&    my $type = $upload\->info\->{"Content\-type"};.Ve.Sh "type".IX Subsection "type".Vb 1\&    $upload\->type().Ve.PPReturns the \s-1MIME\s0 type of the given \fIApache2::Upload\fR object..PP.Vb 1\&    my $type = $upload\->type;\&\&    #same as\&    my $content_type = $upload\->info\->{"Content\-Type"};\&    $content_type =~ s/;.*$//ms;.Ve.Sh "link".IX Subsection "link".Vb 1\&    $upload\->link().Ve.PPTo avoid recopying the upload's internal tempfile brigade on a*nix\-like system, \fIlink\fR will create a hard link to it:.PP.Vb 3\&  my $upload = $req\->upload(\*(Aqfoo\*(Aq);\&  $upload\->link("/path/to/newfile") or\&      die sprintf "link from \*(Aq%s\*(Aq failed: $!", $upload\->tempname;.Ve.PPTypically the new name must lie on the same device and partitionas the brigade's tempfile.  If this or any other reason preventsthe \s-1OS\s0 from linking the files, \f(CW\*(C`link()\*(C'\fR will insteadcopy the temporary file to the specified location..Sh "slurp".IX Subsection "slurp".Vb 1\&    $upload\->slurp($contents).Ve.PPReads the full contents of a file upload into the scalar argument.The return value is the length of the file..PP.Vb 1\&    my $size = $upload\->slurp($contents);.Ve.Sh "tempname".IX Subsection "tempname".Vb 1\&    $upload\->tempname().Ve.PPProvides the name of the spool file..PP.Vb 1\&    my $tempname = $upload\->tempname;.Ve.SH "APR::Request::Brigade".IX Header "APR::Request::Brigade"This class is derived from APR::Brigade, providing additionalmethods for \s-1TIEHANDLE\s0, \s-1READ\s0 and \s-1READLINE\s0.  To be memory efficient,these methods delete buckets from the brigade as soon as theirdata is actually read, so you cannot \f(CW\*(C`seek\*(C'\fR on handles tied tothis class.  Such handles have semantics similar to that of aread-only socket..Sh "\s-1TIEHANDLE\s0".IX Subsection "TIEHANDLE".Vb 1\&    APR::Request::Brigade\->TIEHANDLE($bb).Ve.PPCreates a copy of the bucket brigade represented by \f(CW$bb\fR, andblesses that copy into the APR::Request::Brigade class.  Thisprovides syntactic sugar for using perl's builtin \f(CW\*(C`read\*(C'\fR, \f(CW\*(C`readline\*(C'\fR,and \f(CW\*(C`<>\*(C'\fR operations on handles tied to this package:.PP.Vb 4\&    use Symbol;\&    $fh = gensym;\&    tie *$fh, "APR::Request:Brigade", $bb;\&    print while <$fh>;.Ve.Sh "\s-1READ\s0".IX Subsection "READ".Vb 3\&    $bb\->READ($contents)\&    $bb\->READ($contents, $length)\&    $bb\->READ($contents, $length, $offset).Ve.PPReads data from the brigade \f(CW$bb\fR into \f(CW$contents\fR.  When omitted\&\f(CW$length\fR defaults to \f(CW\*(C`\-1\*(C'\fR, which reads the first bucket into \f(CW$contents\fR.A positive \f(CW$length\fR will read in \f(CW$length\fR bytes, or the remainder of thebrigade, whichever is greater. \f(CW$offset\fR represents the index in \f(CW$context\fRto read the new data..Sh "\s-1READLINE\s0".IX Subsection "READLINE".Vb 1\&    $bb\->READLINE().Ve.PPReturns the first line of data from the bride. Lines are terminated bylinefeeds (the '\e012' character), but we may eventually use \f(CW$/\fR instead..SH "PORTING from 1.X".IX Header "PORTING from 1.X".IP "\(bu" 4\&\f(CW\*(C`$upload\->next()\*(C'\fR is no longer available;  please use the\&\f(CW\*(C`APR::Request::Param::Table\*(C'\fR \s-1API\s0 when iterating over upload entries..IP "\(bu" 4\&\f(CW\*(C`info($header_name)\*(C'\fR is replaced by \f(CW\*(C`info($set)\*(C'\fR..IP "\(bu" 4\&\f(CW\*(C`type()\*(C'\fR returns only the MIME-type portion of the Content-Type header..SH "SEE ALSO".IX Header "SEE ALSO"APR::Request::Param::Table, APR::Request::Error, Apache2::Request,\&\fIAPR::Table\fR\|(3).SH "COPYRIGHT".IX Header "COPYRIGHT".Vb 1\&  Copyright 2003\-2006  The Apache Software Foundation\&\&  Licensed 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..Ve

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?