1Mojo::Asset(3)        User Contributed Perl Documentation       Mojo::Asset(3)
2
3
4

NAME

6       Mojo::Asset - HTTP content storage base class
7

SYNOPSIS

9         package Mojo::Asset::MyAsset;
10         use Mojo::Base 'Mojo::Asset';
11
12         sub add_chunk {...}
13         sub contains  {...}
14         sub get_chunk {...}
15         sub move_to   {...}
16         sub mtime     {...}
17         sub size      {...}
18         sub slurp     {...}
19         sub to_file   {...}
20

DESCRIPTION

22       Mojo::Asset is an abstract base class for HTTP content storage
23       backends, like Mojo::Asset::File and Mojo::Asset::Memory.
24

EVENTS

26       Mojo::Asset inherits all events from Mojo::EventEmitter.
27

ATTRIBUTES

29       Mojo::Asset implements the following attributes.
30
31   end_range
32         my $end = $asset->end_range;
33         $asset  = $asset->end_range(8);
34
35       Pretend file ends earlier.
36
37   start_range
38         my $start = $asset->start_range;
39         $asset    = $asset->start_range(3);
40
41       Pretend file starts later.
42

METHODS

44       Mojo::Asset inherits all methods from Mojo::EventEmitter and implements
45       the following new ones.
46
47   add_chunk
48         $asset = $asset->add_chunk('foo bar baz');
49
50       Add chunk of data to asset. Meant to be overloaded in a subclass.
51
52   contains
53         my $position = $asset->contains('bar');
54
55       Check if asset contains a specific string. Meant to be overloaded in a
56       subclass.
57
58   get_chunk
59         my $bytes = $asset->get_chunk($offset);
60         my $bytes = $asset->get_chunk($offset, $max);
61
62       Get chunk of data starting from a specific position, defaults to a
63       maximum chunk size of 131072 bytes (128KiB).  Meant to be overloaded in
64       a subclass.
65
66   is_file
67         my $bool = $asset->is_file;
68
69       False, this is not a Mojo::Asset::File object.
70
71   is_range
72         my $bool = $asset->is_range;
73
74       Check if asset has a "start_range" or "end_range".
75
76   move_to
77         $asset = $asset->move_to('/home/sri/foo.txt');
78
79       Move asset data into a specific file. Meant to be overloaded in a
80       subclass.
81
82   mtime
83         my $mtime = $asset->mtime;
84
85       Modification time of asset. Meant to be overloaded in a subclass.
86
87   size
88         my $size = $asset->size;
89
90       Size of asset data in bytes. Meant to be overloaded in a subclass.
91
92   slurp
93         my $bytes = $asset->slurp;
94
95       Read all asset data at once. Meant to be overloaded in a subclass.
96
97   to_file
98         my $file = $asset->to_file;
99
100       Convert asset to Mojo::Asset::File object. Meant to be overloaded in a
101       subclass.
102

SEE ALSO

104       Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
105
106
107
108perl v5.32.1                      2021-02-07                    Mojo::Asset(3)
Impressum