# File lib/dragonfly/data_storage/file_data_store.rb, line 50 def destroy(relative_path) validate_uid!(relative_path) path = absolute(relative_path) FileUtils.rm path FileUtils.rm_f meta_data_path(path) FileUtils.rm_f deprecated_meta_data_path(path) purge_empty_directories(relative_path) rescue Errno::ENOENT => e raise DataNotFound, e.message end
# File lib/dragonfly/data_storage/file_data_store.rb, line 74 def disambiguate(path) dirname = File.dirname(path) basename = File.basename(path, '.*') extname = File.extname(path) "#{dirname}/#{basename}_#{(Time.now.usec*10 + rand(100)).to_s(32)}#{extname}" end
# File lib/dragonfly/data_storage/file_data_store.rb, line 39 def retrieve(relative_path) validate_uid!(relative_path) path = absolute(relative_path) pathname = Pathname.new(path) raise DataNotFound, "couldn't find file #{path}" unless pathname.exist? [ pathname, (store_meta ? retrieve_meta_data(path) : {}) ] end
# File lib/dragonfly/data_storage/file_data_store.rb, line 17 def store(temp_object, opts={}) relative_path = if opts[:path] opts[:path] else filename = temp_object.name || 'file' relative_path = relative_path_for(filename) end begin path = absolute(relative_path) until !File.exist?(path) path = disambiguate(path) end temp_object.to_file(path).close store_meta_data(path, temp_object.meta) if store_meta rescue Errno::EACCES => e raise UnableToStore, e.message end relative(path) end
# File lib/dragonfly/data_storage/file_data_store.rb, line 61 def url_for(relative_path, opts={}) if server_root.nil? raise NotConfigured, "you need to configure server_root for #{self.class.name} in order to form urls" else _, __, path = absolute(relative_path).partition(server_root) if path.empty? raise UnableToFormUrl, "couldn't form url for uid #{relative_path.inspect} with root_path #{root_path.inspect} and server_root #{server_root.inspect}" else path end end end
Generated with the Darkfish Rdoc Generator 2.