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 關注
- 98 瀏覽
添加回答
舉報