<<

NAME

DBIx::Class::InflateColumn::File - DEPRECATED (superseded by DBIx::Class::InflateColumn::FS)

Deprecation Notice

 This component has a number of architectural deficiencies that can quickly
 drive your filesystem and database out of sync and is not recommended for
 further use. It will be retained for backwards compatibility, but no new
 functionality patches will be accepted. Please consider using the much more
 mature and actively supported DBIx::Class::InflateColumn::FS. You can set
 the environment variable DBIC_IC_FILE_NOWARN to a true value to disable
 this warning.

SYNOPSIS

In your DBIx::Class table class:

    use base 'DBIx::Class::Core';

    __PACKAGE__->load_components(qw/InflateColumn::File/);

    # define your columns
    __PACKAGE__->add_columns(
        "id",
        {
            data_type         => "integer",
            is_auto_increment => 1,
            is_nullable       => 0,
            size              => 4,
        },
        "filename",
        {
            data_type           => "varchar",
            is_file_column      => 1,
            file_column_path    =>'/tmp/uploaded_files',
            # or for a Catalyst application 
            # file_column_path  => MyApp->path_to('root','static','files'),
            default_value       => undef,
            is_nullable         => 1,
            size                => 255,
        },
    );

In your Catalyst::Controller class:

FileColumn requires a hash that contains IO::File as handle and the file's name as name.

    my $entry = $c->model('MyAppDB::Articles')->create({ 
        subject => 'blah',
        filename => { 
            handle => $c->req->upload('myupload')->fh, 
            filename => $c->req->upload('myupload')->basename 
        },
        body => '....'
    });
    $c->stash->{entry}=$entry;

And Place the following in your TT template

    Article Subject: [% entry.subject %]
    Uploaded File: 
    <a href="/static/files/[% entry.id %]/[% entry.filename.filename %]">File</a>
    Body: [% entry.body %]

The file will be stored on the filesystem for later retrieval. Calling delete on your resultset will delete the file from the filesystem. Retrevial of the record automatically inflates the column back to the set hash with the IO::File handle and filename.

DESCRIPTION

InflateColumn::File

METHODS

_file_column_callback ($file,$ret,$target)

Method made to be overridden for callback purposes.

INHERITED METHODS

DBIx::Class::InflateColumn

get_inflated_column, inflate_column, set_inflated_column, store_inflated_column

DBIx::Class::Row

MULTICREATE_DEBUG, discard_changes, get_column, get_columns, get_dirty_columns, get_from_storage, get_inflated_columns, has_column_loaded, in_storage, inflate_result, insert_or_update, is_changed, is_column_changed, make_column_dirty, new, result_source, set_column, set_columns, set_inflated_columns, store_column, throw_exception, update, update_or_insert

DBIx::Class

MODIFY_CODE_ATTRIBUTES, component_base_class, mk_classaccessor, mk_classdata

DBIx::Class::Componentised

inject_base

Class::C3::Componentised

ensure_class_found, ensure_class_loaded, load_components, load_optional_class, load_optional_components, load_own_components

Class::Accessor::Grouped

get_component_class, get_inherited, get_simple, get_super_paths, make_group_accessor, make_group_ro_accessor, make_group_wo_accessor, mk_group_accessors, mk_group_ro_accessors, mk_group_wo_accessors, set_component_class, set_inherited, set_simple

INHERITED METHODS

DBIx::Class::InflateColumn

get_inflated_column, inflate_column, set_inflated_column, store_inflated_column

DBIx::Class::Row

MULTICREATE_DEBUG, discard_changes, get_column, get_columns, get_dirty_columns, get_from_storage, get_inflated_columns, has_column_loaded, in_storage, inflate_result, insert_or_update, is_changed, is_column_changed, make_column_dirty, new, result_source, set_column, set_columns, set_inflated_columns, store_column, throw_exception, update, update_or_insert

DBIx::Class

MODIFY_CODE_ATTRIBUTES, component_base_class, mk_classaccessor, mk_classdata

DBIx::Class::Componentised

inject_base

Class::C3::Componentised

ensure_class_found, ensure_class_loaded, load_components, load_optional_class, load_optional_components, load_own_components

Class::Accessor::Grouped

get_component_class, get_inherited, get_simple, get_super_paths, make_group_accessor, make_group_ro_accessor, make_group_wo_accessor, mk_group_accessors, mk_group_ro_accessors, mk_group_wo_accessors, set_component_class, set_inherited, set_simple

AUTHOR

Victor Igumnov

LICENSE

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.

<<