Donovan Daniels
b1c702e3cd
poorly tested but it worked well enough, I'm sure I'll be patching bugs over the next few weeks Also remove turbo because it sucks Also changed the way we handle hosts in dev
30 lines
672 B
Ruby
30 lines
672 B
Ruby
# frozen_string_literal: true
|
|
|
|
module StorageManager
|
|
class Bunny
|
|
attr_reader :base_url, :access_key, :storage_zone_name
|
|
|
|
def initialize(base_url:, access_key:, storage_zone_name:)
|
|
@base_url = base_url
|
|
@access_key = access_key
|
|
@storage_zone_name = storage_zone_name
|
|
end
|
|
|
|
def request
|
|
Requests::Bunny.new(access_key: access_key, storage_zone_name: storage_zone_name)
|
|
end
|
|
|
|
delegate :delete, :exists?, :get, :put, to: :request
|
|
|
|
def upload(path, body)
|
|
r = put(path, body)
|
|
return nil unless r.success?
|
|
"#{base_url}/#{path}"
|
|
end
|
|
|
|
def url_for(entry)
|
|
"#{base_url}#{entry.path}"
|
|
end
|
|
end
|
|
end
|