/** * Saves a file * @param string $sourcePath An absolute local path to a file name to read from. * @param string $destinationFileName A storage file name to save to. * @return bool */ protected function putFile($sourcePath, $destinationFileName = null) { if (!$destinationFileName) { $destinationFileName = $this->disk_name; } $destinationPath = $this->getStorageDirectory() . $this->getPartitionDirectory(); if (!$this->isLocalStorage()) { return $this->copyLocalToStorage($sourcePath, $destinationPath . $destinationFileName); } /* * Using local storage, tack on the root path and work locally * this will ensure the correct permissions are used. */ $destinationPath = $this->getLocalRootPath() . '/' . $destinationPath; if (!FileHelper::isDirectory($destinationPath)) { FileHelper::makeDirectory($destinationPath, 0777, true); } return FileHelper::copy($sourcePath, $destinationPath . $destinationFileName); }