clean
[sgn.git] / lib / SGN / Controller / Metadata.pm
blobad066361e3a4fe200c30bf91e3902204c8ccf68c
1 package SGN::Controller::Metadata;
2 use Moose;
3 use namespace::autoclean;
5 =head1 NAME
7 SGN::Controller::Metadata - stuff involving C<CXGN::Metadata>
9 =head1 ACTIONS
11 =cut
13 use File::Spec::Functions 'catfile';
15 BEGIN { extends 'Catalyst::Controller' }
17 =head2 download_md_file
19 Public path: /metadata/file/<file_id>/download
21 Download a static file pointed to by a
22 L<CXGN::Metadata::Schema::MdFiles> row.
24 =cut
26 sub download_md_file : Chained('get_md_file') PathPart('download') Args(0) {
27 my ( $self, $c ) = @_;
29 $c->stash->{download_filename} = $c->stash->{md_file}->path;
30 $c->forward('/download/download');
33 # chain root (/metadata/file/<file_id>) for doing things with MdFiles
34 sub get_md_file : Chained('/') PathPart('metadata/file') CaptureArgs(1) {
35 my ( $self, $c, $id ) = @_;
36 $id += 0;
38 $c->stash->{md_file} = $c->dbic_schema('CXGN::Biosource::Schema')
39 ->resultset('MdFiles')
40 ->find({ file_id => $id })
41 or $c->throw_404;