Module: UploadDocumentsTool

Defined in:
lib/upload_documents_tool.rb,
lib/upload_documents_tool/version.rb,
lib/upload_documents_tool/validators.rb

Defined Under Namespace

Modules: Validators Classes: Engine

Constant Summary collapse

VERSION =
"0.1.2"
REQUIRED_VALIDATORS =
[AttachmentContentTypeValidator]

Instance Method Summary collapse

Instance Method Details

#initialize(params = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/upload_documents_tool.rb', line 8

def initialize(params = {})
  @file = params.delete(:file)
  super
  if @file
    self.filename = sanitize_filename(@file.original_filename)
    self.content_type = @file.content_type
    self.file_contents = @file.read
  end
end

#upload_localObject



18
19
20
21
22
# File 'lib/upload_documents_tool.rb', line 18

def upload_local
  path = "#{Rails.root}/public/uploads/documents"
  FileUtils.mkdir_p(path) unless File.exists?(path)
  FileUtils.copy(@file.tempfile, path)
end