Put a file on ftp-server.

@param string $oldName
@param string $newName

@return $this
@throws Exception
181468
public function rename(string $oldName, string $newName)
    {
        if (!@ftp_rename($this->ftp, $oldName, $newName)) {
            throw new Exception(sprintf("Cannot rename file from %s to %s", $oldName, $newName));
        }

        return $this;
    }
179802
public function setFileName($fileName)
    {
        $this->fileName = $fileName;
        $this->headers->add(array('Content-Disposition' => 'attachment; filename="' . $this->fileName . '"'));
        return $this;
    }
450886
private function setNewFilename($newfilename = null)
    {
        $extension = $this->results['original_extension'];
        $originalFilename = $this->results['original_filename'];

        $timestamp = Carbon::now()->getTimestamp();

        switch ($this->newfilename) {
            case 'hash':
                $newfilename = md5($originalFilename.$timestamp);
                break;
            case 'random':
                $newfilename = Str::random(16);
                break;
            case 'timestamp':
                $newfilename = $timestamp;
                break;
            case 'custom':
                $newfilename = (! empty($newfilename) ? $newfilename : $originalFilename);
                break;
            default:
                $newfilename = pathinfo($originalFilename, PATHINFO_FILENAME);
        }

        $this->results['basename'] = (string) $newfilename;
        $this->results['filename'] = $newfilename.'.'.$extension;

        return $this;
    }
309649
public function move( $destination, $newName = '' ) {
		$source = $this->file['tmp_name'];

		if ( $destination != '' && substr( $destination, - 1 ) != '/' ) {
			$destination .= '/';
		}

		if ( ! empty( $newName ) ) {
			$target = $destination . $newName;
		} else {
			$target = $destination . $this->file['name'];
		}

		if ( ! @move_uploaded_file( $source, $target ) ) {
			$error = error_get_last();

			throw new FileException(
				sprintf(
					'Could not move the file "%s" to "%s" (%s)',
					$this->getPathname(),
					$target,
					strip_tags( $error['message'] )
				)
			);
		}

		@chmod( $target, 0666 & ~umask() );

		return $target;

	}
515121
public function renameFolder($cb, $oldName, $newName)
    {
        $this->onResponse->push($cb);
        $this->writeln(self::TAG_RENAMEFOLDER . " RENAME "
            .$this->escapeString($oldName)." ".$this->escapeString($newName));
    }
94228
public void setDone(String oldName, String newName) throws IOException {
        Path oldPath = new Path(oldName);
        fs.rename(oldPath, new Path(newName));
    }
311792
public static function putContents(string $filename, $data, bool $override = false)
    {
        $dirname = dirname($filename);
        if (!file_exists($dirname)) {
            mkdir($dirname, 0700, true);
        }
        if (!file_exists($filename) || $override) {
            $result = file_put_contents($filename, $data);
        } else {
            throw new \Exception("{$filename} is already exists");
        }
        return $result;
    }
898157
public function rename(String $oldName, String $newName) : Bool
    {
        if( @ssh2_sftp_rename($this->connect, $oldName, $newName) )
        {
            return true;
        }
        else
        {
            throw new FolderChangeNameException(NULL, $oldName);
        }
    }
789080
public static function rename(String $oldName, String $newName) : Bool
    {
        $oldName = Info::rpath($oldName);

        if( ! file_exists($oldName) )
        {
            throw new Exception\FileNotFoundException(NULL, $oldName);
        }

        return rename($oldName, $newName);
    }
604566
public function put(string $filename, $body): PutCommand
    {
        /** @var PutCommand $command */
        $command = $this->builder->build(PutCommand::class);
        $command->withFilename($filename)->withBody($body);

        return $command;
    }
654826
protected function makeFile($filename, $content, $force)
    {
        if ($this->fileExists($filename, $force)) {
            throw new Exception('The destination file already exists. To override the existing file, pass "--force" option.');
        }

        if (!File::put($filename, $content)) {
            throw new Exception('Unexpected error occurred while trying to create the file. please try your request again.');
        }

        return $this;
    }
842584
public function download($filename) {
    if(!empty($this->pdf->getError())) {
      throw new Exception('Could not create PDF: ' . $this->pdf->getError());
    } else {
      $filename = rtrim(File::create()->setName($filename), '.pdf') . '.pdf';
      $this->pdf->send($filename);
    }
  }
725718
public function renameForeignKey($oldName, $newName)
    {
        if (!$this->hasForeignKey($oldName)) {
            throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasForeignKey($newName)) {
            throw SchemaException::tableForeignKeyAlreadyExists($this->getName(), $newName);
        }

        $this->foreignKeys[$oldName]->setName($newName);
        $this->foreignKeys[$newName] = $this->foreignKeys[$oldName];
        unset($this->foreignKeys[$oldName]);
    }
251285
public function copy($oldPath, $newPath)
    {
        $url = self::BASE_URI.$this->getPathUnderRootDrive($oldPath).':/action.copy';

        $payload = $this->getNewFileLocationPayload($newPath);

        $headers = [
            'Content-Type' => 'application/json',
            'Prefer' => 'respond-async',
        ];

        $response = $this->getResponse('POST', $url, json_encode($payload), $headers);
        $asyncStatusLocation = $response->getHeader('Location');

        //check for the status of an async operation
        $completed = false;
        while (!$completed) {
            $statusResponse = $this->getResponse('GET', $asyncStatusLocation[0]);

            $statusCode = $statusResponse->getStatusCode();
            if ($statusCode == '303' || $statusCode == '200') {
                $completed = true;
            } else {
                $statusRaw = $statusResponse->getBody()->getContents();
                $status = json_decode($statusRaw);
                if ($status->status == 'failed') {
                    throw new OneDriveClientException('API error when copying the file');
                }

                //wait some time until the next status check
                sleep(0.5);
            }
        }

        return $this->getMetadata($newPath);
    }
104667
public function put($remoteFile, $localFile, $startPosision = 0)
    {
        $mode = $this->getMode();
        $result = @ftp_put($this->connection, $remoteFile, $localFile, $mode, $startPosision);
        
        if ($result === false) {
            throw new Exception('Unable to put file');
        }

        return $this;
    }
828899
public function renameSection($oldName, $newName)
    {
        $this->arguments[] = '--rename-section';
        $this->arguments[] = $oldName;
        $this->arguments[] = $newName;
        return $this;
    }
326208
public function rename($oldName, $newName)
    {
        if (! ssh2_sftp_rename($this->sFtp, $oldName, $newName)) {
            throw new \RuntimeException('Name can not be changed');
        }
        return true;
    }