Sha256: 11f74b3960fc77caaf898fcdc177ee17179f016f5fcd1f5a841ba9ea7c889441

Contents?: true

Size: 926 Bytes

Versions: 29

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

module AtlasRb
  class File < Resource
    ROUTE = "/files/"
  end

  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

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
atlas_rb-0.0.58 lib/atlas_rb/file.rb
atlas_rb-0.0.57 lib/atlas_rb/file.rb
atlas_rb-0.0.56 lib/atlas_rb/file.rb
atlas_rb-0.0.54 lib/atlas_rb/file.rb
atlas_rb-0.0.53 lib/atlas_rb/file.rb
atlas_rb-0.0.52 lib/atlas_rb/file.rb
atlas_rb-0.0.51 lib/atlas_rb/file.rb
atlas_rb-0.0.49 lib/atlas_rb/file.rb
atlas_rb-0.0.48 lib/atlas_rb/file.rb
atlas_rb-0.0.47 lib/atlas_rb/file.rb
atlas_rb-0.0.46 lib/atlas_rb/file.rb
atlas_rb-0.0.45 lib/atlas_rb/file.rb
atlas_rb-0.0.42 lib/atlas_rb/file.rb
atlas_rb-0.0.41 lib/atlas_rb/file.rb
atlas_rb-0.0.40 lib/atlas_rb/file.rb
atlas_rb-0.0.39 lib/atlas_rb/file.rb
atlas_rb-0.0.38 lib/atlas_rb/file.rb
atlas_rb-0.0.37 lib/atlas_rb/file.rb
atlas_rb-0.0.36 lib/atlas_rb/file.rb
atlas_rb-0.0.35 lib/atlas_rb/file.rb