Class: Scrivito::Binary
- Inherits:
-
Object
- Object
- Scrivito::Binary
- Defined in:
- lib/scrivito/binary.rb
Overview
The Binary class represents the data stored in a binary attribute of an Obj or Widget
Instance Method Summary collapse
-
#content_length ⇒ Integer
the length of this binary data, in bytes.
-
#content_type ⇒ String
the content type of this binary data, for example “image/jpeg”.
-
#filename ⇒ String
the filename of this binary data, for example “my_image.jpg”.
-
#private? ⇒ Boolean
Some Scrivito data is considered private, i.e.
-
#url ⇒ String
The URL where this binary data is accessible and can be downloaded using an HTTP GET request.
Instance Method Details
#content_length ⇒ Integer
the length of this binary data, in bytes.
52 53 54 |
# File 'lib/scrivito/binary.rb', line 52 def content_length headers[:content_length].to_i end |
#content_type ⇒ String
the content type of this binary data, for example “image/jpeg”
45 46 47 |
# File 'lib/scrivito/binary.rb', line 45 def content_type headers[:content_type] end |
#filename ⇒ String
the filename of this binary data, for example “my_image.jpg”
38 39 40 |
# File 'lib/scrivito/binary.rb', line 38 def filename File.basename(URI(url).path) end |
#private? ⇒ Boolean
Some Scrivito data is considered private, i.e. it is not currently intended for the general public, for example content in a workspace that has not been published yet.
19 20 21 |
# File 'lib/scrivito/binary.rb', line 19 def private? !public_content? end |
#url ⇒ String
The URL where this binary data is accessible and can be downloaded using an HTTP GET request. Note that urls for private content will have an expiration time in order to protect them. Therefore the url returned here should be accessed immediately after it has been returned (i.e. within a couple of minutes). When accessed after they have expired, an error will occur. The urls should not be used for long-term-storage (i.e. they are no longer accessible hours or days after they have been generated).
31 32 33 |
# File 'lib/scrivito/binary.rb', line 31 def url find_url('get') end |