DBIx::Class::InflateColumn::File(3pm)

DBIx::Class::InflateColumn::File3pm

Deprecated (superseded by dbix::class::inflatecolumn::fs)

Usage

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.

Overview

InflateColumn::File

Methods

_file_column_callback ($file,$ret,$target)

Method made to be overridden for callback purposes.

Further questions?

Check the list of additional DBIC resources.

Releases

9 releases since Debian 5.0 (Lenny); the text changed 7 times.

  1. 5.0
  2. 6.0
  3. 7
  4. 8
  5. 9
  6. 10–11
  7. 12
  8. 13

From libdbix-class-perl 0.082844-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.