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
158 159 160 |
# File 'app/models/hyrax/file_metadata.rb', line 158 def to_rdf_representation name end |
Instance Method Details
#content ⇒ #to_s
Deprecated.
get content from #file instead
210 211 212 213 214 215 216 |
# File 'app/models/hyrax/file_metadata.rb', line 210 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
198 199 200 |
# File 'app/models/hyrax/file_metadata.rb', line 198 def download_id id end |
#extracted_file? ⇒ Boolean
177 178 179 |
# File 'app/models/hyrax/file_metadata.rb', line 177 def extracted_file? pcdm_use.include?(Use::EXTRACTED_TEXT) end |
#file ⇒ Valkyrie::StorageAdapter::File
225 226 227 228 229 |
# File 'app/models/hyrax/file_metadata.rb', line 225 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)
184 185 186 |
# File 'app/models/hyrax/file_metadata.rb', line 184 def filtered_pcdm_use pcdm_use.select { |use| Use.use_list.include?(use) } end |
#original_file? ⇒ Boolean
165 166 167 |
# File 'app/models/hyrax/file_metadata.rb', line 165 def original_file? pcdm_use.include?(Use::ORIGINAL_FILE) end |
#thumbnail_file? ⇒ Boolean
171 172 173 |
# File 'app/models/hyrax/file_metadata.rb', line 171 def thumbnail_file? pcdm_use.include?(Use::THUMBNAIL_IMAGE) end |
#title ⇒ Object
194 195 196 |
# File 'app/models/hyrax/file_metadata.rb', line 194 def title label end |
#to_rdf_representation ⇒ String
190 191 192 |
# File 'app/models/hyrax/file_metadata.rb', line 190 def to_rdf_representation self.class.to_rdf_representation end |
#valid? ⇒ Boolean
202 203 204 |
# File 'app/models/hyrax/file_metadata.rb', line 202 def valid? file.valid?(size: recorded_size.first, digests: { sha256: checksum&.first&.sha256 }) end |