Class: AtlasRb::FileSet
Overview
Constant Summary collapse
- ROUTE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Atlas REST endpoint prefix for this resource.
"/file_sets/"
Class Method Summary collapse
-
.create(id, classification, position: nil, idempotency_key: nil, nuid: nil, on_behalf_of: nil) ⇒ Hash
Create a new FileSet under a Work.
-
.destroy(id, nuid: nil, on_behalf_of: nil) ⇒ Faraday::Response
Delete a FileSet.
-
.find(id, nuid: nil, on_behalf_of: nil) ⇒ Hash
Fetch a single FileSet by ID.
-
.update(id, blob_path, nuid: nil, on_behalf_of: nil) ⇒ Hash
Attach (or replace) the binary content backing this FileSet.
Methods inherited from Resource
find_many, history, mods_version, mods_versions, permissions, preview
Methods included from FaradayHelper
#connection, #multipart, #system_connection
Class Method Details
.create(id, classification, position: nil, idempotency_key: nil, nuid: nil, on_behalf_of: nil) ⇒ Hash
Create a new FileSet under a Work.
72 73 74 75 76 77 78 79 |
# File 'lib/atlas_rb/file_set.rb', line 72 def self.create(id, classification, position: nil, idempotency_key: nil, nuid: nil, on_behalf_of: nil) params = { work_id: id, classification: classification } params[:position] = position if position AtlasRb::Mash.new(JSON.parse( connection(params, nuid, on_behalf_of: on_behalf_of, idempotency_key: idempotency_key).post(ROUTE)&.body ))["file_set"] end |
.destroy(id, nuid: nil, on_behalf_of: nil) ⇒ Faraday::Response
Delete a FileSet.
94 95 96 |
# File 'lib/atlas_rb/file_set.rb', line 94 def self.destroy(id, nuid: nil, on_behalf_of: nil) connection({}, nuid, on_behalf_of: on_behalf_of).delete(ROUTE + id) end |
.find(id, nuid: nil, on_behalf_of: nil) ⇒ Hash
Fetch a single FileSet by ID.
30 31 32 33 34 |
# File 'lib/atlas_rb/file_set.rb', line 30 def self.find(id, nuid: nil, on_behalf_of: nil) AtlasRb::Mash.new(JSON.parse( connection({}, nuid, on_behalf_of: on_behalf_of).get(ROUTE + id)&.body ))["file_set"] end |
.update(id, blob_path, nuid: nil, on_behalf_of: nil) ⇒ Hash
Attach (or replace) the binary content backing this FileSet.
The body is uploaded as application/octet-stream regardless of the
file's true type — Atlas inspects the content server-side. To upload
a binary blob plus an original filename, use Blob.create directly
against the underlying /files/ endpoint.
117 118 119 120 121 122 123 124 125 |
# File 'lib/atlas_rb/file_set.rb', line 117 def self.update(id, blob_path, nuid: nil, on_behalf_of: nil) # Need to figure out blob vs XML payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path), "application/octet-stream", File.basename(blob_path)) } AtlasRb::Mash.new(JSON.parse( multipart(nuid, on_behalf_of: on_behalf_of).patch(ROUTE + id, payload)&.body )) end |