NAME

MVC::Neaf::Upload - File upload object for Not Even A Framework

METHODS

Generally, this class isn't used directly; instead, it's returned by an MVC::Neaf::Request object.

new(%options)

%options may include:

  • id (required) - the form id by which upload is known.

  • tempfile - file where upload is stored.

  • handle - file handle opened for readin. One of these is required.

  • filename - user-supplied filename. Don't trust this.

  • utf8 - if set, all data read from the file will be utf8-decoded.

id()

Return upload id.

filename()

Get user-supplied file name. Don't trust this value.

size()

Calculate file size.

CAVEAT May return 0 if file is a pipe.

handle()

Return file handle, opening temp file if needed.

content()

Return file content (aka slurp), caching it in memory.

CAVEAT May eat up a lot of memory. Be careful...

NOTE This breaks file current position, resetting it to the beginning.

rewind()

Reset the file to the beginning. Will fail silently on pipes.

Returns self.

LICENSE AND COPYRIGHT

This module is part of MVC::Neaf suite.

Copyright 2016-2023 Konstantin S. Uvarin khedin@cpan.org.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.