Class: ImageServer::Uploader

Inherits:
Object
  • Object
show all
Defined in:
lib/image_server/uploader.rb

Instance Method Summary collapse

Constructor Details

#initialize(namespace, source, outputs, configuration: ImageServer.configuration) ⇒ Uploader

Returns a new instance of Uploader.



5
6
7
8
9
10
# File 'lib/image_server/uploader.rb', line 5

def initialize(namespace, source, outputs, configuration: ImageServer.configuration)
  @namespace = namespace
  @source = source
  @outputs = outputs
  @configuration = configuration
end

Instance Method Details

#upload(force: false) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/image_server/uploader.rb', line 12

def upload(force: false)
  return existing_image_property if existing_image_property && !force
  uploader = Adapters::Http.new(@namespace, @source, configuration: @configuration)
  properties_json = uploader.upload(uri)

  find_or_create_image_property(properties_json)
rescue PermanentFailure => e
  raise UploadError.new(e.message)
end