<<

NAME

C4::UploadedFile - manage files uploaded by the user for later processing.

SYNOPSIS

# create and store data my $uploaded_file = C4::UploadedFile->new($sessionID); my $fileID = $uploaded_file->id(); $uploaded_file->name('c:\temp\file.mrc'); $uploaded_file->max_size(1024); while ($have_more_data) { $uploaded_file->stash($data, $bytes_read); } $uploaded_file->done();

# check status of current file upload my $progress = C4::UploadedFile->upload_progress($sessionID);

# get file handle for reading uploaded file my $uploaded_file = C4::UploadedFile->fetch($fileID); my $fh = $uploaded_file->fh();

Stores files uploaded by the user from their web browser. The uploaded files are temporary and at present are not guaranteed to survive beyond the life of the user's session.

This module allows for tracking the progress of the file currently being uploaded.

TODO: implement secure persistant storage of uploaded files.

METHODS

new

my $uploaded_file = C4::UploadedFile->new($sessionID);

Creates a new object to represent the uploaded file. Requires the current session ID.

id

my $fileID = $uploaded_file->id();

name

my $name = $uploaded_file->name(); $uploaded_file->name($name);

Accessor method for the name by which the file is to be known.

max_size

my $max_size = $uploaded_file->max_size(); $uploaded_file->max_size($max_size);

Accessor method for the maximum size of the uploaded file.

stash

$uploaded_file->stash($dataref, $bytes_read);

Write $dataref to the temporary file. $bytes_read represents the number of bytes (out of $max_size) transmitted so far.

done

$uploaded_file->done();

Indicates that all of the bytes have been uploaded.

upload_progress

my $upload_progress = C4::UploadFile->upload_progress($sessionID);

Returns (as an integer from 0 to 100) the percentage progress of the current file upload.

fetch

    my $uploaded_file = C4::UploadedFile->fetch($sessionID, $fileID);

Retrieves an uploaded file object from the current session.

fh

my $fh = $uploaded_file->fh();

Returns an IO::File handle to read the uploaded file.

AUTHOR

Koha Development Team <info@koha.org>

Galen Charlton <galen.charlton@liblime.com>

<<