简体   繁体   English

Phar 无法提取文件

[英]Phar unable to extract a file

I`m trying to extract a tar file using Phar Classe, but is returning the following error:我正在尝试使用 Phar Classe 提取 tar 文件,但返回以下错误:

UnexpectedValueException Object ( [message:protected] => phar error: "/home/filelocation/file.tar" is a corrupted tar file (truncated) [string:Exception:private] => [code:protected] => 0 [file:protected] => /home/inplan/public_html/uncompress_files.php [line:protected] => 89 [trace:Exception:private] => Array ( [0] => Array ( [file] => /home/inplan/public_html/uncompress_files.php [line] => 89 [function] => __construct [class] => PharData [type] => -> [args] => Array ( [0] => uploads/maps/true_color_4.tar ) ) ) [previous:Exception:private] => )

PHP: PHP:

try {
    $phar = new PharData('uploads/maps/true_color_'.$id_technical_report.'.tar');
    $phar2 = $phar->convertToExecutable (Phar::TAR,Phar::NONE);
    $phar2->extractTo('uploads/maps/');
} catch (Exception $e) {
    print_r($e);
}

When I download this file, I can open and extract normally using Winrar.当我下载这个文件时,我可以使用Winrar正常打开和解压。

The file is generated by an API from Sentinel Hub ( https://services.sentinel-hub.com/api/v1/process )该文件由 Sentinel Hub ( https://services.sentinel-hub.com/api/v1/process ) 的 API 生成

Any ideas why is this happening?任何想法为什么会发生这种情况?

Thanks谢谢

I got the same message from an homemade tar program building a tar file.我从构建 tar 文件的自制 tar 程序中得到了相同的消息。 I could not untar it with the PHAR class.我无法用 PHAR 类解压它。 The problem was the CRC field, wrote on the last line of the tar file, that was miscalculated by the program that made originely that tar file.问题是 CRC 字段,写在 tar 文件的最后一行,它被最初制作该 tar 文件的程序错误计算了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM