Class: Hyrax::FileMetadata

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

Class Method Details

.to_rdf_representationString

Returns:

  • (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

Returns:

  • (#to_s)


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_idObject



179
180
181
# File 'app/models/hyrax/file_metadata.rb', line 179

def download_id
  id
end

#extracted_file?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'app/models/hyrax/file_metadata.rb', line 165

def extracted_file?
  pcdm_use.include?(Use::EXTRACTED_TEXT)
end

#fileValkyrie::StorageAdapter::File

Returns:

  • (Valkyrie::StorageAdapter::File)

Raises:

  • (Valkyrie::StorageAdapter::AdapterNotFoundError)

    if no adapter could be found matching the file_identifier’s scheme

  • (Valkyrie::StorageAdapter::FileNotFound)

    when the file can’t be found in the registered adapter



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

Returns:

  • (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

Returns:

  • (Boolean)


159
160
161
# File 'app/models/hyrax/file_metadata.rb', line 159

def thumbnail_file?
  pcdm_use.include?(Use::THUMBNAIL_IMAGE)
end

#titleObject



175
176
177
# File 'app/models/hyrax/file_metadata.rb', line 175

def title
  label
end

#to_rdf_representationString

Returns:

  • (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

Returns:

  • (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