Module: PictureHandler::Uploader::FileSystem::File

Defined in:
lib/picture_handler/uploader/file_system/file.rb

Instance Method Summary collapse

Instance Method Details

#delete_all_with_file_systemObject

————————– # —— DELETE —— # ————————– #



27
28
29
30
31
32
33
34
35
36
# File 'lib/picture_handler/uploader/file_system/file.rb', line 27

def delete_all_with_file_system

  infos = info

  #Delete files and directory
  infos[:paths].each { |hash| delete_from_path(hash[:key]) }
  # Delete directory
  Dir.rmdir(infos[:store_dir])

end

#write_file(image, path_to_write) ⇒ Object

————————– # —— WRITE —— # ————————– #



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/picture_handler/uploader/file_system/file.rb', line 10

def write_file(image, path_to_write)

  # Create path if it doesn't exist
  self.class.create_directories_for_path( self.class.split_dirname_path(path_to_write) )

  image.write(path_to_write)

  # Raise an exception if the image is not written at the expected location
  unless ::File.exist?(path_to_write)
    raise PictureHandler::Exceptions::WriteError.new(path_to_write)
  end
end