Class: Vines::Services::Controller::TransfersController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/vines/services/controller/transfers_controller.rb

Defined Under Namespace

Modules: FileUploader

Instance Attribute Summary

Attributes inherited from BaseController

#node, #storage, #stream, #uploads

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, register

Constructor Details

This class inherits a constructor from Vines::Services::Controller::BaseController

Instance Method Details

#processObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vines/services/controller/transfers_controller.rb', line 9

def process
  forbidden! unless current_user.manage_files?
  return unless node.to == stream.jid
  name, size = node.si.file['name'], node.si.file['size'].to_i
  log.debug("Receiving file: #{name}")

  path = File.expand_path(name, uploads)
  return unless path.start_with?(uploads)

  log.debug("Saving file to #{path}")
  File.delete(path) if File.exist?(path)

  save_file_doc(name, size)

  transfer = Blather::FileTransfer.new(stream, node)
  transfer.allow_s5b = false
  transfer.accept(FileUploader, path, size, storage)
end