Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Created March 24, 2014 13:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save emad-elsaid/9740135 to your computer and use it in GitHub Desktop.
Save emad-elsaid/9740135 to your computer and use it in GitHub Desktop.
Uplaod files and images from you android to your desktop/laptop
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
require 'sinatra'
set :port, 3000
set :environment, :production
get '/' do
<<-EOT
<html><head>
</head><body style="padding:0px;margin:0px;">
<form action="/upload" method="post" enctype="multipart/form-data" >
Choose files <input type="file" name="files[]" multiple>
<input type="submit" value="Upload" />
</form>
</body></html>
EOT
end
post '/upload' do
params['files'].each do |f|
tempfile = f[:tempfile]
filename = f[:filename]
FileUtils.copy(tempfile.path, "./#{filename}")
end
redirect '/'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment