Class: Wings::Valkyrie::Storage
- Inherits:
-
Valkyrie::Storage::Fedora
- Object
- Valkyrie::Storage::Fedora
- Wings::Valkyrie::Storage
- Defined in:
- lib/wings/valkyrie/storage.rb
Overview
This is a Wings storage adapter designed for compatibility with Hydra::Pcdm/Hydra::Works.
Where the built-in ‘Valkyrie::Storage::Fedora` adapter uploads files without LDP containment relationships (via HTTP PUT), this adapter supports adding files to a `/files` container when a `FileSet` is passed as the `resource:` argument.
If a non ‘#file_set?` resource is passed, the logic is very similar to the built-in storage adapter.
For use with Hyrax, this adapter defaults to Fedora 4.
Constant Summary collapse
- DEFAULT_CTYPE =
'application/octet-stream'- LINK_HEADER =
"<http://www.w3.org/ns/ldp#NonRDFSource>; rel=\"type\""- FILES_PATH =
'files'
Instance Attribute Summary collapse
-
#sha1 ⇒ Object
readonly
Returns the value of attribute sha1.
Instance Method Summary collapse
-
#initialize(connection: Ldp::Client.new(ActiveFedora.fedora.host), base_path: ActiveFedora.fedora.base_path, fedora_version: 4) ⇒ Storage
constructor
A new instance of Storage.
-
#upload(file:, original_filename:, resource:, content_type: DEFAULT_CTYPE, resource_uri_transformer: default_resource_uri_transformer, use: Hydra::PCDM::Vocab::PCDMTerms.File, id_hint: 'original', **extra_arguments) ⇒ Object
rubocop:disable Metrics/ParameterLists.
Constructor Details
#initialize(connection: Ldp::Client.new(ActiveFedora.fedora.host), base_path: ActiveFedora.fedora.base_path, fedora_version: 4) ⇒ Storage
Returns a new instance of Storage.
25 26 27 28 |
# File 'lib/wings/valkyrie/storage.rb', line 25 def initialize(connection: Ldp::Client.new(ActiveFedora.fedora.host), base_path: ActiveFedora.fedora.base_path, fedora_version: 4) @sha1 = fedora_version == 5 ? "sha" : "sha1" super end |
Instance Attribute Details
#sha1 ⇒ Object (readonly)
Returns the value of attribute sha1.
23 24 25 |
# File 'lib/wings/valkyrie/storage.rb', line 23 def sha1 @sha1 end |
Instance Method Details
#upload(file:, original_filename:, resource:, content_type: DEFAULT_CTYPE, resource_uri_transformer: default_resource_uri_transformer, use: Hydra::PCDM::Vocab::PCDMTerms.File, id_hint: 'original', **extra_arguments) ⇒ Object
rubocop:disable Metrics/ParameterLists
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wings/valkyrie/storage.rb', line 30 def upload(file:, original_filename:, resource:, content_type: DEFAULT_CTYPE, # rubocop:disable Metrics/ParameterLists resource_uri_transformer: default_resource_uri_transformer, use: Hydra::PCDM::Vocab::PCDMTerms.File, id_hint: 'original', **extra_arguments) id = if resource.try(:file_set?) upload_with_works(resource: resource, file: file, use: use) else put_file(file: file, original_filename: original_filename, resource: resource, content_type: content_type, resource_uri_transformer: resource_uri_transformer, id_hint: id_hint, **extra_arguments) end find_by(id: ::Valkyrie::ID.new(id.to_s.sub(/^.+\/\//, PROTOCOL))) end |