line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mongoose::File; |
2
|
|
|
|
|
|
|
$Mongoose::File::VERSION = '2.01'; |
3
|
1
|
|
|
1
|
|
7
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has file_id => ( is => 'ro', isa => 'BSON::OID', required => 1 ); |
6
|
|
|
|
|
|
|
has bucket => ( is => 'ro', isa => 'MongoDB::GridFSBucket', required => 1 ); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has stream_download => |
9
|
|
|
|
|
|
|
is => 'ro', |
10
|
|
|
|
|
|
|
isa => 'MongoDB::GridFSBucket::DownloadStream', |
11
|
|
|
|
|
|
|
lazy => 1, |
12
|
|
|
|
|
|
|
default => sub { $_[0]->bucket->open_download_stream($_[0]->file_id) }, |
13
|
|
|
|
|
|
|
handles => [qw/ fh readline read eof fileno getc /]; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
1
|
|
sub slurp { local $/; shift->readline; } |
|
0
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub delete { |
18
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
19
|
0
|
|
|
|
|
|
$self->bucket->delete($self->file_id); |
20
|
0
|
|
|
|
|
|
$self->file_id; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
*drop = \&delete; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Mongoose::File - container for MongoDB::GridFSBucket files |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This module is automatically used when your class |
32
|
|
|
|
|
|
|
has C<FileHandle> type attributes. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
It wraps L<MongoDB::GridFSBucket::DownloadStream> and adds a |
35
|
|
|
|
|
|
|
few convenience methods to it. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 METHODS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 delete |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Deletes the GridFS file entry. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 drop |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Same as delete |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 slurp |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Retrieve the full content of the file at once. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |