/** * 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. */ 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); }
/** * Saves a file * @param string $sourcePath An absolute path to a file name to read from. * @param string $destinationFileName A file name without a path to save to. */ protected function putFile($sourcePath, $destinationFileName = null) { if (!$destinationFileName) { $destinationFileName = $this->disk_name; } $destinationPath = $this->getStorageDirectory() . $this->getPartitionDirectory(); if (!FileHelper::isDirectory($destinationPath)) { FileHelper::makeDirectory($destinationPath, 0777, true); } return FileHelper::copy($sourcePath, $destinationPath . $destinationFileName); }
/** * 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. */ 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; /* * Verify the directory exists, if not try to create it. If creation fails * because the directory was created by a concurrent process then proceed, * otherwise trigger the error. */ if (!FileHelper::isDirectory($destinationPath) && !FileHelper::makeDirectory($destinationPath, 0777, true, true) && !FileHelper::isDirectory($destinationPath)) { trigger_error(error_get_last(), E_USER_WARNING); } return FileHelper::copy($sourcePath, $destinationPath . $destinationFileName); }