# File lib/fog/storage/models/local/file.rb, line 70 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, 'w') 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