]> git.imager.perl.org - bse.git/blob - site/cgi-bin/modules/BSE/StorageMgr/Files.pm
632d6065801163b248b8bcf339d992582cca48c6
[bse.git] / site / cgi-bin / modules / BSE / StorageMgr / Files.pm
1 package BSE::StorageMgr::Files;
2 use strict;
3 use BSE::StorageMgr::Base;
4 our @ISA = qw(BSE::StorageMgr::Base);
5 use BSE::Storage::LocalFiles;
6 use BSE::Util::ContentType qw(content_type);
7
8 sub filebase {
9   my ($self) = @_;
10
11   my $path = $self->cfg->entryVar('paths', 'downloads');
12
13   $path =~ m!/$! or $path .= '/';
14
15   return $path;
16 }
17
18 sub local_class {
19   return 'BSE::Storage::LocalFiles';
20 }
21
22 sub type {
23   'files';
24 }
25
26 sub files {
27   require BSE::TB::ArticleFiles;
28   return BSE::TB::ArticleFiles->file_storages;
29 }
30
31 sub metadata {
32   my ($self, $file) = @_;
33
34   if ($file->{download}) {
35     return
36       (
37        content_type => "application/octet-stream",
38        content_disposition => "attachment; filename=$file->{displayName}",
39       );
40   }
41   else {
42     return
43       (
44        content_type => $file->{contentType},
45        content_disposition => "inline; filename=$file->{displayName}",
46       );
47   }
48 }
49
50 sub set_src {
51   my ($self, $file, $src) = @_;
52
53   $file->{src} = $src;
54   $file->save;
55 }
56
57
58 1;