6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/fake_ftp/server_commands/stor.rb', line 6
def run(ctx, filename = '', *)
if ctx.active? && ctx.command_state[:active_connection].nil?
ctx.respond_with('425 Ain\'t no data port!')
return
end
ctx.respond_with('125 Do it!')
data_client = if ctx.active?
ctx.command_state[:active_connection]
else
ctx.data_server.accept
end
data = data_client.read(nil)
ctx.store[ctx.abspath(filename)] = FakeFtp::File.new(
filename.to_s, data, ctx.mode
)
data_client.close
ctx.command_state[:active_connection] = nil
'226 Did it!'
end
|