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) ⇒ Hash
Create a new FileSet under a Work.
-
.destroy(id) ⇒ Faraday::Response
Delete a FileSet.
-
.find(id) ⇒ Hash
Fetch a single FileSet by ID.
-
.update(id, blob_path) ⇒ Hash
Attach (or replace) the binary content backing this FileSet.
Methods inherited from Resource
Methods included from FaradayHelper
Class Method Details
.create(id, classification) ⇒ Hash
Create a new FileSet under a Work.
40 41 42 |
# File 'lib/atlas_rb/file_set.rb', line 40 def self.create(id, classification) JSON.parse(connection({ work_id: id, classification: classification }).post(ROUTE)&.body)["file_set"] end |
.destroy(id) ⇒ Faraday::Response
Delete a FileSet.
51 52 53 |
# File 'lib/atlas_rb/file_set.rb', line 51 def self.destroy(id) connection({}).delete(ROUTE + id) end |
.find(id) ⇒ Hash
Fetch a single FileSet by ID.
24 25 26 |
# File 'lib/atlas_rb/file_set.rb', line 24 def self.find(id) JSON.parse(connection({}).get(ROUTE + id)&.body)["file_set"] end |
.update(id, blob_path) ⇒ 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.
68 69 70 71 72 73 74 |
# File 'lib/atlas_rb/file_set.rb', line 68 def self.update(id, blob_path) # Need to figure out blob vs XML payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path), "application/octet-stream", File.basename(blob_path)) } JSON.parse(multipart({}).patch(ROUTE + id, payload)&.body) end |