1DBIx::Class::InflateColUusmenr::CFoinlter(i3b)uted PerlDDBoIcxu:m:eCnltaastsi:o:nInflateColumn::File(3)
2
3
4
6 DBIx::Class::InflateColumn::File - map files from the Database to the
7 filesystem.
8
10 In your DBIx::Class table class:
11
12 use base 'DBIx::Class::Core';
13
14 __PACKAGE__->load_components(qw/InflateColumn::File/);
15
16 # define your columns
17 __PACKAGE__->add_columns(
18 "id",
19 {
20 data_type => "integer",
21 is_auto_increment => 1,
22 is_nullable => 0,
23 size => 4,
24 },
25 "filename",
26 {
27 data_type => "varchar",
28 is_file_column => 1,
29 file_column_path =>'/tmp/uploaded_files',
30 # or for a Catalyst application
31 # file_column_path => MyApp->path_to('root','static','files'),
32 default_value => undef,
33 is_nullable => 1,
34 size => 255,
35 },
36 );
37
38 In your Catalyst::Controller class:
39
40 FileColumn requires a hash that contains IO::File as handle and the
41 file's name as name.
42
43 my $entry = $c->model('MyAppDB::Articles')->create({
44 subject => 'blah',
45 filename => {
46 handle => $c->req->upload('myupload')->fh,
47 filename => $c->req->upload('myupload')->basename
48 },
49 body => '....'
50 });
51 $c->stash->{entry}=$entry;
52
53 And Place the following in your TT template
54
55 Article Subject: [% entry.subject %]
56 Uploaded File:
57 <a href="/static/files/[% entry.id %]/[% entry.filename.filename %]">File</a>
58 Body: [% entry.body %]
59
60 The file will be stored on the filesystem for later retrieval. Calling
61 delete on your resultset will delete the file from the filesystem.
62 Retrevial of the record automatically inflates the column back to the
63 set hash with the IO::File handle and filename.
64
66 InflateColumn::File
67
69 _file_column_callback ($file,$ret,$target)
70 Method made to be overridden for callback purposes.
71
73 Victor Igumnov
74
76 This library is free software, you can redistribute it and/or modify it
77 under the same terms as Perl itself.
78
79
80
81perl v5.12.0 2010-05-12DBIx::Class::InflateColumn::File(3)