write filenames of uploaded files to log file
This commit is contained in:
parent
a94e97253d
commit
f877e8ad78
11
server.rb
11
server.rb
|
@ -1,9 +1,9 @@
|
|||
require 'sinatra'
|
||||
|
||||
set :bind, '0.0.0.0'
|
||||
set :bind, '127.0.0.1'
|
||||
set :port, '35257'
|
||||
|
||||
USERS = { 'christoffermadsen' => 'lolol', 'gre' => 'lol'}
|
||||
USERS = { 'christoffermadsen' => 'lolol' }
|
||||
FILENAME_GENERATOR = lambda {rand(36**6).to_s(36)}
|
||||
|
||||
|
||||
|
@ -25,9 +25,14 @@ post '/upload' do
|
|||
impure_filename = (request['filename'] || FILENAME_GENERATOR.call) << ".png"
|
||||
filename = sanitize_filename(impure_filename)
|
||||
|
||||
File.open filename, 'w+' do |f|
|
||||
puts ENV['HOME']
|
||||
File.open "#{ENV['HOME']}/public_html/screenshots/#{filename}", 'w+' do |f|
|
||||
f << request['imagedata'][:tempfile].read
|
||||
end
|
||||
|
||||
File.open "uploads.log", 'a+' do |log|
|
||||
log << filename
|
||||
end
|
||||
|
||||
return [200, filename]
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user