Class: Scrivito::Binary

Inherits:
Object
  • Object
show all
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

Instance Method Details

#content_lengthInteger

the length of this binary data, in bytes.



50
51
52
# File 'lib/scrivito/binary.rb', line 50

def content_length
  headers[:content_length].to_i
end

#content_typeString

the content type of this binary data, for example “image/jpeg”



43
44
45
# File 'lib/scrivito/binary.rb', line 43

def content_type
  headers[:content_type]
end

#filenameString

the filename of this binary data, for example “my_image.jpg”



36
37
38
# File 'lib/scrivito/binary.rb', line 36

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.



17
18
19
# File 'lib/scrivito/binary.rb', line 17

def private?
  !public_content?
end

#urlString

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).



29
30
31
# File 'lib/scrivito/binary.rb', line 29

def url
  find_url('get')
end