# File lib/fog/local/models/file.rb, line 79 def save(options = {}) requires :body, :directory, :key # Once 1.9.3 support is dropped, the following two lines # can be replaced with `File.dirname(path)` dirs = path.split(::File::SEPARATOR)[0...-1] dir_path = dirs.join(::File::SEPARATOR) # Create all directories in file path that do not yet exist FileUtils.mkdir_p(dir_path) if (body.is_a?(::File) || body.is_a?(Tempfile)) && ::File.exist?(body.path) FileUtils.cp(body.path, path) else write_file(path, body) end merge_attributes( :content_length => Fog::Storage.get_body_size(body), :last_modified => ::File.mtime(path) ) true end