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
- #original_file? ⇒ Boolean
- #thumbnail_file? ⇒ Boolean
- #title ⇒ Object
- #to_rdf_representation ⇒ String
- #valid? ⇒ Boolean
Class Method Details
.to_rdf_representation ⇒ String
146 147 148 |
# File 'app/models/hyrax/file_metadata.rb', line 146 def to_rdf_representation name end |
Instance Method Details
#content ⇒ #to_s
Deprecated.
get content from #file instead
191 192 193 194 195 196 197 |
# File 'app/models/hyrax/file_metadata.rb', line 191 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
179 180 181 |
# File 'app/models/hyrax/file_metadata.rb', line 179 def download_id id end |
#extracted_file? ⇒ Boolean
165 166 167 |
# File 'app/models/hyrax/file_metadata.rb', line 165 def extracted_file? pcdm_use.include?(Use::EXTRACTED_TEXT) end |
#file ⇒ Valkyrie::StorageAdapter::File
206 207 208 209 210 |
# File 'app/models/hyrax/file_metadata.rb', line 206 def file Valkyrie::StorageAdapter .adapter_for(id: file_identifier) .find_by(id: file_identifier) end |
#original_file? ⇒ Boolean
153 154 155 |
# File 'app/models/hyrax/file_metadata.rb', line 153 def original_file? pcdm_use.include?(Use::ORIGINAL_FILE) end |
#thumbnail_file? ⇒ Boolean
159 160 161 |
# File 'app/models/hyrax/file_metadata.rb', line 159 def thumbnail_file? pcdm_use.include?(Use::THUMBNAIL_IMAGE) end |
#title ⇒ Object
175 176 177 |
# File 'app/models/hyrax/file_metadata.rb', line 175 def title label end |
#to_rdf_representation ⇒ String
171 172 173 |
# File 'app/models/hyrax/file_metadata.rb', line 171 def to_rdf_representation self.class.to_rdf_representation end |
#valid? ⇒ Boolean
183 184 185 |
# File 'app/models/hyrax/file_metadata.rb', line 183 def valid? file.valid?(size: recorded_size.first, digests: { sha256: checksum&.first&.sha256 }) end |