Module: Gluttonberg::Library::Storage::Filesystem::InstanceMethods
- Defined in:
- lib/gluttonberg/library/storage/filesystem.rb
Instance Method Summary collapse
- #assets_directory_public_url ⇒ Object
-
#directory ⇒ Object
The generated directory where this file is located.
- #make_backup ⇒ Object
- #move_tmp_file_to_actual_directory(file_name, tmp_file_dirty = true) ⇒ Object
- #remove_file_from_storage ⇒ Object
- #remove_file_from_tmp_storage ⇒ Object
- #tmp_directory ⇒ Object
- #update_file_on_storage ⇒ Object
Instance Method Details
#assets_directory_public_url ⇒ Object
31 32 33 |
# File 'lib/gluttonberg/library/storage/filesystem.rb', line 31 def assets_directory_public_url "/user_assets" end |
#directory ⇒ Object
The generated directory where this file is located. If it is an image it’s thumbnails will be stored here as well.
21 22 23 24 |
# File 'lib/gluttonberg/library/storage/filesystem.rb', line 21 def directory Filesystem::ClassMethods.storage_setup if Library.root.blank? Library.root + "/" + self.asset_hash end |
#make_backup ⇒ Object
35 36 37 38 39 40 |
# File 'lib/gluttonberg/library/storage/filesystem.rb', line 35 def make_backup unless File.exist?(original_file_on_disk) FileUtils.cp location_on_disk, original_file_on_disk FileUtils.chmod(0755,original_file_on_disk) end end |
#move_tmp_file_to_actual_directory(file_name, tmp_file_dirty = true) ⇒ Object
63 64 65 66 67 |
# File 'lib/gluttonberg/library/storage/filesystem.rb', line 63 def move_tmp_file_to_actual_directory(file_name , tmp_file_dirty=true) if self.file_dirty == true self.file_dirty = false end end |
#remove_file_from_storage ⇒ Object
42 43 44 45 46 |
# File 'lib/gluttonberg/library/storage/filesystem.rb', line 42 def remove_file_from_storage if File.exists?(directory) FileUtils.rm_r(directory) end end |
#remove_file_from_tmp_storage ⇒ Object
48 49 50 |
# File 'lib/gluttonberg/library/storage/filesystem.rb', line 48 def remove_file_from_tmp_storage # just dummy method. As we don't need to remove because tmp and actual folder is same for filesystem end |
#tmp_directory ⇒ Object
26 27 28 29 |
# File 'lib/gluttonberg/library/storage/filesystem.rb', line 26 def tmp_directory Filesystem::ClassMethods.storage_setup if Library.tmp_root.blank? Library.tmp_root + "/" + self.asset_hash end |
#update_file_on_storage ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/gluttonberg/library/storage/filesystem.rb', line 52 def update_file_on_storage if file FileUtils.mkdir(directory) unless File.exists?(directory) FileUtils.cp file.tempfile.path, location_on_disk FileUtils.chmod(0755, location_on_disk) # new file has been upload, if its image generate thumbnails, if mp3 collect sound info. asset_processing end end |