Class: Uploader
- Inherits:
-
Object
show all
- Includes:
- Logging
- Defined in:
- lib/flickrup/uploader.rb
Instance Method Summary
collapse
Methods included from Logging
logger, #logger, pre_init
Constructor Details
#initialize(flickr_client) ⇒ Uploader
Returns a new instance of Uploader.
13
14
15
|
# File 'lib/flickrup/uploader.rb', line 13
def initialize(flickr_client)
@flickr = flickr_client
end
|
Instance Method Details
#prepare_upload_properties(ctx) ⇒ Object
35
36
37
|
# File 'lib/flickrup/uploader.rb', line 35
def prepare_upload_properties(ctx)
{:tags => ctx.file.tags.to_s}.merge(ctx.properties)
end
|
#upload(ctx) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/flickrup/uploader.rb', line 17
def upload(ctx)
if ctx.properties[UploaderConstants::NO_UPLOAD]
logger.info("Skipping upload of #{ctx.file.filename} as marked as NO_UPLOAD")
else
logger.info("Uploading #{ctx.file.filename} with tags #{ctx.file.tags}")
begin
rv = @flickr.upload_photo(ctx.file.filename, prepare_upload_properties(ctx))
logger.info("Uploaded #{ctx.file.filename}")
rescue StandardError => err
logger.error("Failed to upload #{ctx.file.filename}: #{err}")
end
end
rv
end
|