php - GAE 上的 PHP ZipArchive 返回只读文件系统
问题描述
我一直在尝试使用 Google App Engine 和 PHP 的 ZipArchive 来压缩可能存储桶中的一个文件,然后将该 zip 文件存储在存储桶中。我基本上一直在向它添加错误检查,并且已经深入到只读文件系统消息。存储桶和应用程序在同一个项目中。不知道从这里去哪里。有任何想法吗?下面是我的测试代码和结果。
$zip = new ZipArchive();
$filename = "gs://my_bucket/new_zip_file.zip";
$toadd = 'gs://my_bucket/MakeaZip.txt';
if (file_exists($toadd)) {
echo "The file $toadd exists<br>";
} else {
echo "The file $toadd does not exist<br>";
}
if (is_writable('gs://my_bucket')) {
echo 'Folder is writable<br>';
} else {
echo 'Folder not writable<br>';
}
if ($zip->open($filename, ZipArchive::CREATE)!==TRUE) {
echo 'Can not open '.$filename.'<br>';
} else {
echo 'Can open '.$filename.'<br>';
}
$content = file_get_contents($toadd);
$zip->addFromString(pathinfo ( $toadd, PATHINFO_BASENAME), $content);
echo "numfiles: " . $zip->numFiles . '<br>';
echo "status:" . $zip->status . '<br>';
echo 'GetStatusString: '.$zip->getStatusString() . '<br>';
$ret = $zip->close();
echo 'Closed with: ' . ($ret ? "true" : "false") . '<br>';
echo 'GetStatusString: '.$zip->getStatusString() . '<br>';
上述代码的结果是:
文件 gs://my_bucket/MakeaZip.txt 存在
文件夹可写
Can open gs://my_bucket/new_zip_file.zip
numfiles: 1
status:0
GetStatusString: No error
Closed with: false
GetStatusString:创建临时文件失败:只读文件系统
解决方案
推荐阅读
- ionic-framework - 在 Ionic 4 中为 ion-button 添加 webkit-backface-visibility
- jsp - 无法包含来自应用程序外部位置的 jsp 文件
- jquery - jQuery - 从数组中获取元素并以相同的顺序输入每个连续的 td
- r - R - 根据列中的值将一列分成两部分
- swift - 在 Tabbar 项目上设置用户的个人资料图片
- java - Intellij IDEA中的步骤导航问题与黄瓜4.6.0
- c++ - CGAL_USE_BASIC_VIEWER
- java - 从依赖中使用的源集中排除单个文件
- c# - Unity - 使用编辑器块功能创建 EditorWindow(如 EditorUtility.DisplayDialog)
- android - 单击android上的Firebase通知时如何使用Web浏览器?