Sha256: ac73ffb4fa323c00f06632f401424d87390723fdea209d93ec87b43a4fc080b8

Contents?: true

Size: 958 Bytes

Versions: 3

Compression:

Stored size: 958 Bytes

Contents

# frozen_string_literal: true

module AtlasRb
  class Blob < Resource
    ROUTE = "/files/"

    def self.find(id)
      connection({}).get(ROUTE + id)&.body
    end

    def self.create(id, blob_path)
      payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path),
                                                          "application/octet-stream",
                                                          File.basename(blob_path)) }

      multipart({ work_id: id }).post(ROUTE, payload)&.body
    end

    def self.destroy(id)
      connection({}).delete(ROUTE + id)
    end

    def self.update(id, blob_path)
      payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path),
                                                          "application/octet-stream",
                                                          File.basename(blob_path)) }
      multipart({}).patch(ROUTE + id, payload)&.body
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
atlas_rb-0.0.64 lib/atlas_rb/blob.rb
atlas_rb-0.0.63 lib/atlas_rb/blob.rb
atlas_rb-0.0.61 lib/atlas_rb/blob.rb