3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/quickmug/upload.rb', line 3
def self.process(args)
raise ArgumentError.new('You must specify an image') if args.empty?
image = File.expand_path(args[0])
caption = args[1..-1].join(' ')
raise ArgumentError.new('The specified file does not exist') unless File.exists?(image)
raise ArgumentError.new('You must specify album in ~/.quickmug') unless QuickMug.config['album']
data = {:AlbumID => QuickMug.config['album']}
if caption.length > 0
data[:Caption] = caption
end
File.open(image, "rb") do |f|
data = QuickMug.client.upload_media(data.merge(:file => f))
end
Image.fromApi(data)
end
|