Upload the current client file by sFTP.

@param $operation

@return bool
421067
private function operationSftp($operation)
    {
        $config = $this->operationFtpConfig($operation);

        $adapter    = new SftpAdapter($config);
        $filesystem = new Filesystem($adapter);

        $written = false;
        if ($stream = fopen($this->file->getLocation(), 'r+')) {
            $this->setLogs($this->file->getLocation(), 'sftpUploading');
            $written = $filesystem->writeStream($this->file->getName(), $stream);
            if (is_resource($stream)) {
                fclose($stream);
            }
            $this->setLogs($written, 'sftpConfirmed');
            if (!$written) {
                $this->setLogs('Could not confirm file upload via SFTP', 'error');
            } else {
                $this->setLogs($filesystem->has($this->file->getName()), 'sftpConfirmed2');
            }
        } else {
            $this->setLogs('Unable to open file for upload via SFTP.', 'error');
        }

        return $written;
    }
640207
protected function uploadFile () : bool
	{
		// Determine the destination
		$this->newFileLocation = $this->getUploadDir().$this->uploadFileDir.getConstant('DS', TRUE).$this->newFileName;			  
		// Make sure a file doesn't already exist in the target location
		if (file_exists($this->newFileLocation)):
			$this->error = "The file {$this->newFileLocation} already exists.";
			return FALSE;
		endif;
		// Attempt to move/upload the file 
		if (!move_uploaded_file($this->tempPath, $this->newFileLocation)):
			// File was not moved - failure.
			$this->error = "The file upload failed.";
			return FALSE;
		endif;
		// SUCCESS
		return TRUE;
	}
854693
function upload($args)
    {
        $args['status'] = false;

        $cache = $this->get_cache();
        $key   = $this->_key($args);
        $data  = file_get_contents($args['path']);

        if ($data === false) {
            return $args;
        }

        $data   = base64_encode($data);
        $status = $cache->write($key, $data);

        if ($status) {
            $args['id']     = $key;
            $args['status'] = true;
            $args['path']   = null;
        }

        return $args;
    }
628139
private function operationFtpConfig($operation)
    {
        $config         = [];
        $config['host'] = isset($operation->host) ? trim($operation->host) : null;
        if (!$config['host']) {
            $this->setLogs('Host is required.', 'error');

            return false;
        } else {
            // Remove schema/port/etc from the host.
            $host = parse_url($config['host'], PHP_URL_HOST);
            if ($host) {
                $config['host'] = $host;
            }
            $this->setLogs($config['host'], 'host');
        }
        $config['username'] = isset($operation->user) ? trim($operation->user) : null;
        if (!$config['username']) {
            $this->setLogs('User is required.', 'error');

            return false;
        } else {
            $this->setLogs($config['username'], 'user');
        }
        $config['password'] = isset($operation->pass) ? trim($operation->pass) : null;
        if (!$config['password']) {
            unset($config['password']);
            $this->setLogs('Password is blank. Assuming anonymous access.', 'warning');
        } else {
            $this->setLogs(str_repeat('*', strlen($config['password'])), 'password');
        }

        $config['privateKey'] = isset($operation->privateKey) ? trim($operation->privateKey) : null;
        if (!$config['privateKey']) {
            unset($config['privateKey']);
        } else {
            $this->setLogs(true, 'privateKey');
        }

        $config['port'] = isset($operation->port) ? (int) $operation->port : null;
        if (!$config['port']) {
            unset($config['port']);
        } else {
            $this->setLogs($config['port'], 'port');
        }

        if ($this->test && isset($operation->rootTest)) {
            $config['root'] = isset($operation->rootTest) ? trim($operation->rootTest) : null;
        }
        if (empty($config['root'])) {
            $config['root'] = isset($operation->root) ? trim($operation->root) : null;
        }
        if (!$config['root']) {
            unset($config['root']);
        } else {
            $this->setLogs($config['root'], 'root');
        }

        $config['passive'] = isset($operation->passive) ? (bool) $operation->passive : true;
        $this->setLogs($config['passive'], 'passive');

        $config['timeout'] = isset($operation->timeout) ? (int) $operation->timeout : 90;
        $this->setLogs($config['timeout'], 'timeout');

        $config['ssl'] = isset($operation->ssl) ? (bool) $operation->ssl : false;
        $this->setLogs($config['ssl'], 'ssl');

        return $config;
    }
109130
public function addOperation(Operation $operation) {
        $operations = $this->getOperations();
        $operations[] = $operation;
        $this->setOperations($operations);
    }
863611
public function lock($resource, int $operation): bool
    {
        if ((LOCK_NB & $operation) == LOCK_NB) {
            $operation = $operation - LOCK_NB;
        }

        // call to lock file on the same file handler firstly releases the lock
        $this->unlock($resource);

        if (LOCK_EX === $operation) {
            if ($this->isLocked()) {
                return false;
            }

            $this->setExclusiveLock($resource);
        } elseif(LOCK_SH === $operation) {
            if ($this->hasExclusiveLock()) {
                return false;
            }

            $this->addSharedLock($resource);
        }

        return true;
    }
623027
public function put($local_file = null, $remote_file = null, $mode = FTP_ASCII)
    {
        if (\ftp_put($this->_stream, $remote_file, $local_file, $mode)) {
            return true;
        }

        $this->error = 'Failed to upload file "'.$local_file.'"';

        return false;
    }
414533
public function uploaded( $temp, $to )
    {
        if ( null === $this->identity )
        {
            return false;
        }

        if ( is_array( $temp ) || is_object( $temp ) ||
             is_array( $to )   || is_object( $to ) )
        {
            if ( ( ! is_array( $temp ) && ! is_object( $temp ) ) ||
                 ( ! is_array( $to )   && ! is_object( $to ) ) )
            {
                return false;
            }

            $result = array();

            foreach ( $temp as $key => $p )
            {
                foreach ( $to as $toKey => $t )
                {
                    if ( $key == $toKey )
                    {
                        $result[$key] = $this->uploaded( $p, $t );
                    }
                }
            }

            return $result;
        }

        $to     = $this->secureFile( $this->validPath( $this->realPath( $to ) ) );
        $base   = $this->baseDir . self::UPLOADS_TEMP;
        $full   = realpath( $base . '/' . $temp );
        $toBase = $this->baseUrl . '/' . $to;
        $toFull = $this->baseDir . '/' . $toBase;

        if ( ! empty( $to ) && ! is_dir( dirname( $toFull ) ) )
        {
            $ba = '/' . basename( $to );
            $to = $this->createDir( dirname( $to ) );

            if ( ! $to )
            {
                return false;
            }

            $to     = $to . $ba;
            $toBase = $this->baseUrl . '/' . $to;
            $toFull = $this->baseDir . '/' . $toBase;
        }

        if ( is_file( $full ) && is_dir( dirname( $toFull ) ) )
        {
            if ( $this->rights( $to )->write )
            {
                if ( @ rename( $full, $toFull ) )
                {
                    return $to;
                }
            }
        }

        return false;
    }
904310
function cmd_STOR($fd, $cmd)
    {
        $user = $this->getUser($fd);
        $ftpsock = $this->getUserSock($user);
        $file = $this->fillDirName($user, $cmd[1]);
        $this->debug("PUT: $file");
        $fp = fopen($file, "w");
        if (!$fp)
        {
            $this->send($fd, "553 Can't open that file: Permission denied");
        }
        else
        {
            $this->send($fd, "150 Connecting to client");
            while (!feof($ftpsock))
            {
                $cont = fread($ftpsock, 8192);
                if (!$cont) break;
                if (!fwrite($fp, $cont)) break;
            }
            if (fclose($fp) and $this->closeUserSock($user))
            {
                $this->send($fd, "226 File successfully transferred");
            }
            else
            {
                $this->send($fd, "550 Error during file-transfer");
            }
        }
    }
1330769
public function upload($path, $contents, Config $config)
    {
        $connection = $this->getConnection();
        $this->ensureDirectory(Util::dirname($path));
        $config = Util::ensureConfig($config);

        if (! $connection->put($path, $contents, SFTP::SOURCE_STRING)) {
            return false;
        }

        if ($config && $visibility = $config->get('visibility')) {
            $this->setVisibility($path, $visibility);
        }

        return true;
    }
947388
protected function shouldRefreshFileThumbnails($fileOperation)
    {
        $app = Application::getFacadeApplication();
        $em = $app->make(EntityManagerInterface::class);
        $qb = $em->createQueryBuilder();
        $qb
            ->select('ft.ftTypeID')
            ->from(ThumbnailType::class, 'ft')
            ->innerJoin('ft.ftAssociatedFileSets', 'ftfs')
            ->andWhere($qb->expr()->eq('ftfs.ftfsFileSetID', ':fsID'))
            ->setParameter('fsID', $this->getFileSetID())
            ->andWhere($qb->expr()->eq('ft.ftLimitedToFileSets', ':limitedTo'))
            ->setParameter('limitedTo', $fileOperation === 'add')
            ->setMaxResults(1)
        ;
        $query = $qb->getQuery();

        return $query->getOneOrNullResult($query::HYDRATE_SINGLE_SCALAR) !== null;
    }
748525
public function postPersistNewEvent(Operation $operation, $content = null)
    {
        $this->publishNow($operation);
        $this->em->persist($content);
        $this->em->flush();
    }
1036618
public function upload(String $localPath, String $remotePath) : Bool
    {
        if( @ssh2_scp_send($this->connect, $localPath, $remotePath) )
        {
            return true;
        }
        else
        {
            throw new FileRemoteUploadException(NULL, $localPath);
        }
    }
1342762
private function toProcessFile($entity, $operation)
    {
        switch ($operation) {
            case self::ENCRYPT:
                return !$entity->isFileEncrypted();
            case self::DECRYPT:
                return $entity->isFileEncrypted();
            default:
                return false;
        }
    }
1075221
public function upload($filename, $destination)
    {
        if (isset($this[$filename])) {
            $file = $this[$filename];
            if (is_uploaded_file($file[static::TMP_NAME])) {
                try {
                    return move_uploaded_file($file[static::TMP_NAME], $destination);
                } catch (\Exception $e) {
                    var_dump($e->getMessage());
                    exit();
                }
            }
        }
        return false;
    }
554034
public function upload()
    {
        $filename = $this->getName(true);

        if ( ! is_readable($filename) ) {
            throw new FileExistException('Image file from disk is not readable');
        }

        try {
            $this->getSoapClient()->UploadImage(array(
                'image'    => base64_encode(file_get_contents($filename)) ,
                'filename' => basename($filename) ,
            ));

            return $this;
        } catch ( SoapException $e ) {
            throw new UploadException('Error while uploading the image' , $e);
        }
    }
941217
function send($op,$data='') {
		$server=$this->server;
		$mask=WS::Finale | $op & WS::OpCode;
		$len=strlen($data);
		$buf='';
		if ($len>0xffff)
			$buf=pack('CCNN',$mask,0x7f,$len);
		else
		if ($len>0x7d)
			$buf=pack('CCn',$mask,0x7e,$len);
		else
			$buf=pack('CC',$mask,$len);
		$buf.=$data;
		if (is_bool($server->write($this->socket,$buf)))
			return FALSE;
		if (!in_array($op,[WS::Pong,WS::Close]) &&
			isset($this->events['send']) &&
			is_callable($func=$this->events['send']))
			$func($this,$op,$data);
		return $data;
	}