Get file detail

@param LibraryType $library        Library instance
@param string      $remoteFilePath Remote file path

@return DirectoryItem
@throws \GuzzleHttp\Exception\GuzzleException
@throws Exception
501767
public function getFileDetail(LibraryType $library, string $remoteFilePath): DirectoryItem
    {
        $url = $this->client->getConfig('base_uri')
            . '/repos/'
            . $library->id
            . '/file/detail/'
            . '?p=' . $this->urlEncodePath($remoteFilePath);

        $response = $this->client->request('GET', $url);

        $json = json_decode((string)$response->getBody());

        return (new DirectoryItem)->fromJson($json);
    }
1163931
public function getUploadUrl(LibraryType $library, bool $newFile = true)
    {
        $url = $this->client->getConfig('base_uri')
            . '/repos/'
            . $library->id
            . '/' . ($newFile ? 'upload' : 'update') . '-link/';

        $response = $this->client->request('GET', $url);
        $uploadLink = (string)$response->getBody();

        return preg_replace("/\"/", '', $uploadLink);
    }
130858
public function getFile($remote, $local)
    {
        return ftp_get($this->connection, $local, $remote, $this->getTransferenceEncoding($remote));
    }
907966
public static function send($filePath, $remoteFileSystem)
    {
        return (new Client())->put($remoteFileSystem, ['body' => fopen($filePath, self::READ_BINARY)])
            ->getStatusCode() == HttpHelper::STATUS_OK;
    }
1205810
public static function getXmlContentFromFile ($filePath)
    {
        // Detect media type
        $finfo         = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
        $fileMediaType = finfo_file($finfo, $filePath);
        finfo_close($finfo);

        // Act upon detected media type
        switch ($fileMediaType) {
            case 'application/xml':
                $fileContent = file_get_contents($filePath);
                break;
            case 'application/x-gzip':
                $fileContent = self::gunzip($filePath);
                break;
            case 'application/zip':
                $fileContent = self::unzip($filePath);
                break;
            default:
                throw new Exception("Unsupported file media type: $fileMediaType");
        }

        return $fileContent;
    }
1222522
public function download($remote_path, $local_path, $mode = 'auto')
	{
		if ( ! $this->_is_conn())
		{
			return false;
		}

		// Set the mode if not specified
		if ($mode == 'auto')
		{
			// Get the file extension so we can set the upload type
			$ext = pathinfo($remote_path, PATHINFO_BASENAME);
			$mode = $this->_settype($ext);
		}

		$mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;

		$result = @ftp_get($this->_conn_id, $local_path, $remote_path, $mode);

		if ($result === false)
		{
			if ($this->_debug === true)
			{
				throw new \FtpFileAccessException('Unable to download');
			}
			return false;
		}

		return true;
    }
1286931
public static function getTplTargetPath(string $repoDir, string $targetPath) : string
    {
        $repo    = explode(DIRECTORY_SEPARATOR, ltrim($repoDir, DIRECTORY_SEPARATOR));
        $target  = explode(DIRECTORY_SEPARATOR, ltrim($targetPath, DIRECTORY_SEPARATOR));

        if (!StorageUtil::isSubDirectoryOf($target, $repo)) {
            return '\'' . $targetPath;
        }

        return '__DIR__ . \'/../../' . StorageUtil::getSubPathOf($target, $repo);
    }
364186
public function getById($libraryId): LibraryType
    {
        $response = $this->client->request(
            'GET',
            $this->client->getConfig('base_uri') . '/repos/' . $libraryId . '/'
        );

        $json = json_decode($response->getBody());

        return (new LibraryType)->fromJson($json);
    }
808362
function get_file($srcpath, $localpath) {

        $localpath = $this->utf_decode_path($localpath);

        $handle = fopen($localpath, 'wb');
        if ($handle) {
            $unused = '';
            $ret = $this->get($srcpath, $unused, $handle);
            fclose($handle);
            if ($ret) {
                return true;
            }
        }
        return false;
    }
132688
public function get($local_file, $remote_file, $overwrite = false)
    {
        if (false === $overwrite && true === file_exists($local_file)) {
            return $this->_trigger_error(sprintf('Local file already exists: %s.', $local_file));
        }

        $remote_file = $this->_getAbsoluteRemotePath($remote_file);
        if (false === file_exists($remote_file)) {
            return $this->_trigger_error(sprintf('Could not open remote file: %s.', $remote_file));
        }

        if (false === @copy($remote_file, $local_file)) {
            return $this->_trigger_error(sprintf('Could not send data from file %s to file %s.', $remote_file, $local_file));
        }

        return true;
    }
1245812
public function getFolder($container, $path, $include_files = true, $include_folders = true, $full_tree = false)
    {
        $path = FileUtilities::fixFolderPath($path);
        $delimiter = ($full_tree) ? '' : DIRECTORY_SEPARATOR;
        $resources = [];
        $dirPath = FileUtilities::fixFolderPath(static::asFullPath(''));
        if (is_dir($dirPath)) {
            $localizer = $path;
            $results = static::listTree($dirPath, $path, $delimiter);
            foreach ($results as $data) {
                $fullPathName = $data['path'];
                $data['name'] = rtrim(substr($fullPathName, strlen($localizer)), '/');
                if ('/' == substr($fullPathName, -1, 1)) {
                    // folders
                    if ($include_folders) {
                        $data['type'] = 'folder';
                        $resources[] = $data;
                    }
                } else {
                    // files
                    if ($include_files) {
                        $data['type'] = 'file';
                        $resources[] = $data;
                    }
                }
            }
        } else {
            if (!empty($path)) {
                throw new NotFoundException("Folder '$path' does not exist in storage.");
            }
            // container root doesn't really exist until first write creates it
        }

        return $resources;
    }
1332649
public function getSize(string $remoteFile)
    {
        $size = @ftp_size($this->ftp, $remoteFile);

        if ($size == -1) {
            throw new Exception("Cannot get file size");
        }

        return $size;
    }
985525
public function create(LibraryType $library, DirectoryItem $item): bool
    {
        // do not allow empty paths
        if (empty($item->path) || empty($item->name)) {
            return false;
        }

        $uri = sprintf(
            '%s/repos/%s/file/?p=%s',
            $this->clipUri($this->client->getConfig('base_uri')),
            $library->id,
            $this->urlEncodePath($item->path . $item->name)
        );

        $response = $this->client->request(
            'POST',
            $uri,
            [
                'headers'   => ['Accept' => 'application/json'],
                'multipart' => [
                    [
                        'name'     => 'operation',
                        'contents' => 'create',
                    ],
                ],
            ]
        );

        return $response->getStatusCode() === 201;
    }
1106914
public function getStorageBaseDirectory($basePath = null)
    {
        // Get base storage path configuration
        $storage = $this->get('storage');

        // Check if storage is relative to the application path or not
        $relative = $storage['path_is_relative'] ?: true;

        return ($relative ? $basePath . DIRECTORY_SEPARATOR : '') . $storage['base_dir'];
    }
1276972
protected function getFileAsset($filePath)
    {
        $file = new \SplFileInfo($filePath);

        if (!$file->isReadable() || $file->isDir()) {
            return null;
        }

        $filePath = $file->getRealPath();

        return new FileAsset($filePath);
    }
593658
public function download(String $remotePath, String $localPath) : Bool
    {
        if( @ssh2_scp_recv($this->connect, $remotePath, $localPath) )
        {
            return true;
        }
        else
        {
            throw new FileRemoteDownloadException(NULL, $localPath);
        }
    }
475598
private static String getResource(Bundle myBundle, String resourcePath) {
        if (myBundle == null)
            return null;
        String bundleShortDescription = getBundleDescription(myBundle);
        StringBuilder responseString = new StringBuilder();
        URL bundleResource = myBundle.getResource(resourcePath);
        if (bundleResource != null) {
            BufferedReader br = null;
            try { // read the requested resource from the bundle
                br = new BufferedReader(new InputStreamReader(bundleResource.openConnection().getInputStream(), "UTF-8"));
                while (br.ready()) {
                    responseString.append(br.readLine());
                }
                br.close();
            } catch (Exception e) { // shouldn't happen
                if (OpenAPIUtils.isEventEnabled(tc)) {
                    Tr.event(tc, "Exception trying to read resource at " + resourcePath + " from bundle " + bundleShortDescription);
                }
            }

        } else {
            if (OpenAPIUtils.isEventEnabled(tc)) {
                Tr.event(tc, "Unexpected error getting resource from WAB bundle.");
            }
        }
        return responseString.toString();
    }