Class: Dumpy::Uploader

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

Class Method Summary collapse

Class Method Details

.upload(filename) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dumpy.rb', line 9

def self.upload(filename)
    url = "http://dumpy.io/upload.php"
    download_link = "http://dumpy.io/download.php?q="
    begin 
      current_dir = `pwd`
      file = current_dir.strip + "/" + filename
      
      begin
 data = RestClient.post(url, :file => File.new(file))
      rescue => e
e.response
      end
      
      data = JSON.parse(data)
      Clipboard.copy download_link+data[0]
      puts "Your link was copied to your clipboard. Just paste it! \nThe download link will be valid for 3 days. \n:-) \n"
    rescue => e
      puts "Something's wrong."
    end
end