Class: RackFile
- Inherits:
-
Object
- Object
- RackFile
- Defined in:
- lib/opens3/rack_file.rb
Instance Method Summary collapse
-
#initialize(temp_file, filename, type, bucket, path) ⇒ RackFile
constructor
A new instance of RackFile.
- #save ⇒ Object
Constructor Details
#initialize(temp_file, filename, type, bucket, path) ⇒ RackFile
Returns a new instance of RackFile.
2 3 4 5 6 7 8 |
# File 'lib/opens3/rack_file.rb', line 2 def initialize(temp_file, filename, type, bucket, path) @temp_file = temp_file.path @filename = filename @type = type @bucket = bucket @path = path end |
Instance Method Details
#save ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/opens3/rack_file.rb', line 10 def save begin key = String.new.random_string file_md5 = Digest::MD5.hexdigest(@temp_file) folder_name = Digest::MD5.hexdigest("#{@file_md5}-#{Time.now}-#{key}") path = "#{@path}/#{@bucket}/#{@filename}" FileUtils.mkdir_p(path) = Hash.new ['type']= @type ['md5'] = file_md5 ['filename'] = @filename = .to_yaml File.open("#{path}/meta", 'w') do |out| out.write() end FileUtils.mv(@temp_file, "#{path}/content") rescue SystemCallError false end end |