1 回答
TA贡献1853条经验 获得超6个赞
根本原因似乎在append的来源。
$this->put($path, $this->get($path).$separator.$data);
这将获取文件内容,然后连接数据并将文件放回原处。不知道为什么这样做,但我猜这是因为所有存储类型都不支持以追加模式打开文件,并且必须Storage
实现CloudFilesystemContract
这意味着它适用于云存储(你通常不能“追加” " 到一个文件)。
深入挖掘可以发现 Laravel 的“驱动程序”由FlysystemStorage
支持,并且其接口中不包含功能,因此 Laravel 只能使用提供的接口方法来实现一个功能。append
您始终可以推出自己的解决方案:
// if total size equals length of file we have gathered all patch files
if ($size == $length) {
// write patches to file
foreach ($patch as $filename) {
// get offset from filename
list($dir, $offset) = explode('.patch.', $filename, 2);
// read patch and close
$patch_contents = Storage::disk('tmp')->get($filename);
// apply patch
$fhandle = fopen($dir.$name, "a"); // You may need to adjust the filename
fwrite($fhandle, $patch_contents);
fclose($fhandle);
}
// remove patches
foreach ($patch as $filename) {
Storage::disk('tmp')->delete($filename);
}
}
- 1 回答
- 0 关注
- 80 浏览
添加回答
举报