Module: Aploader

Defined in:
lib/aploader.rb,
lib/aploader/version.rb

Overview

Current Usage: filename = ‘something’ base64string = ‘something’ processed_bin = Aploader.find(filename) || Aploader.create(base64string, filename) if !processed_bin.nil?

processed_bin.file

end

Defined Under Namespace

Classes: TmpFile

Constant Summary collapse

TMP_DIR =
'tmp'
VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.create(url_or_file, filename = nil, options = {}) ⇒ Object



19
20
21
22
23
# File 'lib/aploader.rb', line 19

def create(url_or_file, filename=nil, options={})
  bp = TmpFile.new(filename)
  bp.process!(url_or_file, options)
  return bp
end

.find(filename) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/aploader.rb', line 25

def find(filename)
  path = self.generate_path(filename)
  if File.exists?(path)
    return TmpFile.new(path.split('/').last.split('.').first, :file)
  end
  return nil
end

.generate_path(filename) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/aploader.rb', line 33

def generate_path(filename)
  if filename.split('.').size > 1
    return "#{TMP_DIR}/#{filename}"
  else
    return "#{TMP_DIR}/#{filename}.jpg"
  end
end