NAME LibreCat::App::Catalogue::Controller::File

Helper methods for handling file uploads.

METHODS

upload_temp_file(params->{file},$creator)

Given an upload file handle and a creator string this function will create a temporary storage file for the upload. Returns a JSON document containing the file details:

    {
        # Fields needed for managing the upload
        'tempid'       => 'LJCyFMzwjN',
        'file_name'    => 'find.gif',

        # Metadata fields that can be overwritten by the user
        'access_level' => 'open_access',
        'open_access'  => 1,
        'relation'     => 'main_file',

        # Read-only fields
        'content_type' => 'image/gif',
        'creator'      => 'einstein',
        'date_created' => '2016-05-31T11:05:22Z',
        'date_updated' => '2016-05-31T11:05:22Z',
        'file_size'    => '66658',

        # Success/failure indicator
        'success'      => 1,
    }

handle_file($pub)

For the given publication HASH update the file section (upload files, generate thumbnails) when required. Metadata (but not the technical metadata) of existing files will be changed when required. New files should at least contain 'tempid' and 'file_name'

update_file($file)

Update one $pub->{file}->[<item>] with technical metadata found in the file store. Returns the updated file on success or undef on failure.