# File lib/fog/local/models/storage/file.rb, line 17 def body attributes[:body] ||= if last_modified collection.get(identity).body else '' end end
# File lib/fog/local/models/storage/file.rb, line 25 def body=(new_body) attributes[:body] = new_body end
# File lib/fog/local/models/storage/file.rb, line 29 def content_type @content_type ||= begin unless (mime_types = ::MIME::Types.of(key)).empty? mime_types.first.content_type end end end
# File lib/fog/local/models/storage/file.rb, line 41 def copy(target_directory_key, target_file_key, options={}) requires :directory, :key service.copy_object(directory.key, key, target_directory_key, target_file_key) target_directory = service.directories.new(:key => target_directory_key) target_directory.files.get(target_file_key) end
# File lib/fog/local/models/storage/file.rb, line 48 def destroy requires :directory, :key ::File.delete(path) if ::File.exists?(path) dirs = path.split(::File::SEPARATOR)[0...-1] dirs.length.times do |index| dir_path = dirs[0..-index].join(::File::SEPARATOR) if dir_path.empty? # path starts with ::File::SEPARATOR next end # don't delete the containing directory or higher if dir_path == service.path_to(directory.key) break end pwd = Dir.pwd if ::File.exists?(dir_path) && ::File.directory?(dir_path) Dir.chdir(dir_path) if Dir.glob('*').empty? Dir.rmdir(dir_path) end Dir.chdir(pwd) end end true end
# File lib/fog/local/models/storage/file.rb, line 37 def directory @directory end
# File lib/fog/local/models/storage/file.rb, line 73 def public=(new_public) new_public end
# File lib/fog/local/models/storage/file.rb, line 77 def public_url requires :directory, :key if service.endpoint escaped_directory = URI.escape(directory.key) escaped_key = URI.escape(key) ::File.join(service.endpoint, escaped_directory, escaped_key) else nil end end
# File lib/fog/local/models/storage/file.rb, line 90 def save(options = {}) requires :body, :directory, :key dirs = path.split(::File::SEPARATOR)[0...-1] dirs.length.times do |index| dir_path = dirs[0..index].join(::File::SEPARATOR) if dir_path.empty? # path starts with ::File::SEPARATOR next end # create directory if it doesn't already exist unless ::File.directory?(dir_path) Dir.mkdir(dir_path) end end file = ::File.new(path, 'wb') if body.is_a?(String) file.write(body) else file.write(body.read) end file.close merge_attributes( :content_length => Fog::Storage.get_body_size(body), :last_modified => ::File.mtime(path) ) true end
Generated with the Darkfish Rdoc Generator 2.