Created
December 6, 2016 18:04
-
-
Save michaeljklein/9fb2a41653a8479a58a13048242c42de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless Rails.env.production? | |
require 'ftpd' | |
require 'tmpdir' | |
puts "****** loading tmp_ftp *********" | |
class TmpFtp | |
def initialize(temp_dir) | |
@temp_dir = temp_dir | |
end | |
def authenticate(user, password) | |
true | |
end | |
def file_system(user) | |
Ftpd::DiskFileSystem.new(@temp_dir) | |
end | |
end | |
Dir.mktmpdir do |temp_dir| | |
driver = TmpFtp.new(temp_dir) | |
server = Ftpd::FtpServer.new(driver) | |
server.start | |
puts "Server listening on port #{server.bound_port}" | |
sleep 5.minutes | |
puts "exiting" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment