<<

NAME

Koha::Uploader - Facilitate file uploads (temporary and permanent)

SYNOPSIS

    use Koha::Uploader;
    use Koha::UploadedFile;
    use Koha::UploadedFiles;

    # add an upload (see tools/upload-file.pl)
    # the public flag allows retrieval via OPAC
    my $upload = Koha::Uploader->new( public => 1, category => 'A' );
    my $cgi = $upload->cgi;
    # Do something with $upload->count, $upload->result or $upload->err

    # get some upload records (in staff) via Koha::UploadedFiles
    my @uploads1 = Koha::UploadedFiles->search({ filename => $name });
    my @uploads2 = Koha::UploadedFiles->search_term({ term => $term });

    # staff download (via Koha::UploadedFile[s])
    my $rec = Koha::UploadedFiles->find( $id );
    my $fh = $rec->file_handle;
    print Encode::encode_utf8( $input->header( $rec->httpheaders ) );
    while( <$fh> ) { print $_; }
    $fh->close;

DESCRIPTION

    This module is a refactored version of C4::UploadedFile but adds on top
    of that the new functions from report 6874 (Upload plugin in editor).
    That report added module UploadedFiles.pm. This module contains the
    functionality of both.

    The module has been revised to use Koha::Object[s]; the delete method
    has been moved to Koha::UploadedFile[s], as well as the get method.

INSTANCE METHODS

new

    Returns new object based on Class::Accessor.
    Use tmp or temp flag for temporary storage.
    Use public flag to mark uploads as available in OPAC.
    The category parameter is only useful for permanent storage.

cgi

    Returns CGI object. The CGI hook is used to store the uploaded files.

count

    Returns number of uploaded files without errors

result

    Returns a string of id's for each successful upload separated by commas.

err

    Returns hashref with errors in format { file => { code => err }, ... }
    Undefined if there are no errors.

CLASS METHODS

allows_add_by

    allows_add_by checks if $userid has permission to add uploaded files

INTERNAL ROUTINES

AUTHOR

    Koha Development Team
    Larger parts from Galen Charlton, Julian Maurice and Marcel de Rooy

<<