Class: Hyrax::FileMetadata
- Inherits:
-
Valkyrie::Resource
- Object
- Valkyrie::Resource
- Hyrax::FileMetadata
- Includes:
- Hydra::Works::MimeTypes
- Defined in:
- app/models/hyrax/file_metadata.rb
Defined Under Namespace
Modules: Use
Constant Summary collapse
- GENERIC_MIME_TYPE =
'application/octet-stream'
Class Method Summary collapse
Instance Method Summary collapse
-
#content ⇒ #to_s
deprecated
Deprecated.
get content from #file instead
- #download_id ⇒ Object
- #extracted_file? ⇒ Boolean
- #file ⇒ Valkyrie::StorageAdapter::File
-
#filtered_pcdm_use ⇒ Array
Filters out uses not recognized by Hyrax (e.g. fedora.info/definitions/v4/repository#Binary).
- #original_file? ⇒ Boolean
- #thumbnail_file? ⇒ Boolean
- #title ⇒ Object
- #to_rdf_representation ⇒ String
- #valid? ⇒ Boolean
Class Method Details
.to_rdf_representation ⇒ String
173 174 175 |
# File 'app/models/hyrax/file_metadata.rb', line 173 def to_rdf_representation name end |
Instance Method Details
#content ⇒ #to_s
Deprecated.
get content from #file instead
225 226 227 228 229 230 231 |
# File 'app/models/hyrax/file_metadata.rb', line 225 def content Deprecation.warn('This convienince method has been deprecated. ' \ 'Retrieve the file from the storage adapter instead.') file.read rescue Valkyrie::StorageAdapter::FileNotFound '' end |
#download_id ⇒ Object
213 214 215 |
# File 'app/models/hyrax/file_metadata.rb', line 213 def download_id id end |
#extracted_file? ⇒ Boolean
192 193 194 |
# File 'app/models/hyrax/file_metadata.rb', line 192 def extracted_file? pcdm_use.include?(Use::EXTRACTED_TEXT) end |
#file ⇒ Valkyrie::StorageAdapter::File
240 241 242 243 244 |
# File 'app/models/hyrax/file_metadata.rb', line 240 def file Valkyrie::StorageAdapter .adapter_for(id: file_identifier) .find_by(id: file_identifier) end |
#filtered_pcdm_use ⇒ Array
Filters out uses not recognized by Hyrax (e.g. fedora.info/definitions/v4/repository#Binary)
199 200 201 |
# File 'app/models/hyrax/file_metadata.rb', line 199 def filtered_pcdm_use pcdm_use.select { |use| Use.use_list.include?(use) } end |
#original_file? ⇒ Boolean
180 181 182 |
# File 'app/models/hyrax/file_metadata.rb', line 180 def original_file? pcdm_use.include?(Use::ORIGINAL_FILE) end |
#thumbnail_file? ⇒ Boolean
186 187 188 |
# File 'app/models/hyrax/file_metadata.rb', line 186 def thumbnail_file? pcdm_use.include?(Use::THUMBNAIL_IMAGE) end |
#title ⇒ Object
209 210 211 |
# File 'app/models/hyrax/file_metadata.rb', line 209 def title label end |
#to_rdf_representation ⇒ String
205 206 207 |
# File 'app/models/hyrax/file_metadata.rb', line 205 def to_rdf_representation self.class.to_rdf_representation end |
#valid? ⇒ Boolean
217 218 219 |
# File 'app/models/hyrax/file_metadata.rb', line 217 def valid? file.valid?(size: recorded_size.first, digests: { sha256: checksum&.first&.sha256 }) end |