1
# See bottom of file for license and copyright information
5
---+!! package Foswiki::Request::Upload
7
Class to encapsulate uploaded file info.
11
package Foswiki::Request::Upload;
18
---++ ClassMethod new()
20
Constructs a Foswiki::Request::Upload object
25
my ( $proto, %args ) = @_;
26
my $class = ref($proto) || $proto;
28
headers => $args{headers},
29
tmpname => $args{tmpname},
31
return bless $this, $class;
36
---++ ObjectMethod finish()
38
Deletes temp file associated.
42
# Note to developers; please undef *all* fields in the object explicitly,
43
# whether they are references or not. That way this method is "golden
44
# documentation" of the live fields in the object.
47
undef $this->{headers};
49
#SMELL: Note: untaint filename. Taken from CGI.pm
50
# (had to be updated for OSX in Dec2008)
51
$this->tmpFileName =~ m{^([a-zA-Z0-9_\+ \'\":/.\$\\~-]+)$};
53
if ( scalar( unlink($file) ) != 1 ) {
54
throw Error::Simple( "unable to unlink : " . $file );
56
undef $this->{tmpname};
61
---++ ObjectMethod uploadInfo() -> $headers
63
Returns a hashref to information about uploaded
64
file as sent by browser.
69
return $_[0]->{headers};
74
---++ ObjectMethod handle() -> ( $fh )
76
Returns an open filehandle to uploaded file.
81
my $fh = new IO::File( $_[0]->{tmpname}, '<' );
88
---++ ObjectMethod tmpFileName() -> ( $tmpName )
90
Returns the names of temporarly created file.
95
return $_[0]->{tmpname};
100
# Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/
102
# Copyright (C) 2008-2009 Foswiki Contributors. Foswiki Contributors
103
# are listed in the AUTHORS file in the root of this distribution.
104
# NOTE: Please extend that file, not this notice.
106
# Additional copyrights apply to some or all of the code in this
109
# Copyright (C) 1999-2007 Peter Thoeny, peter@thoeny.org
110
# and TWiki Contributors. All Rights Reserved. TWiki Contributors
111
# are listed in the AUTHORS file in the root of this distribution.
113
# This module is based/inspired on Catalyst framework. Refer to
115
# http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7010/lib/Catalyst.pm
117
# for credits and liscence details.
119
# This program is free software; you can redistribute it and/or
120
# modify it under the terms of the GNU General Public License
121
# as published by the Free Software Foundation; either version 2
122
# of the License, or (at your option) any later version. For
123
# more details read LICENSE in the root of this distribution.
125
# This program is distributed in the hope that it will be useful,
126
# but WITHOUT ANY WARRANTY; without even the implied warranty of
127
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
129
# As per the GPL, removal of this notice is prohibited.