I'm trying to merge a file chunked in parts and in Laravel Framework 7.30.4 is not working the append method of Storage/File Facade
foreach($files as $file)
{
$content = Storage::get($file);
Storage::append($tmp_file, $content);
}
When I do it with vanilla php works fine:
foreach($files as $file)
{
$content = Storage::get($file);
file_put_contents(storage_path("app/{$tmp_file}"), $content, FILE_APPEND);
}
the md5 hash results is only correct with the vanilla style, what I'm doing wrong in laravel style?
I'm watching with vbindiff tool and the all the file is equal except the last part.
thank you
CodePudding user response:
I see this code in laravel code:
public function append($path, $data, $separator = PHP_EOL)
{
if ($this->exists($path)) {
return $this->put($path, $this->get($path).$separator.$data);
}
return $this->put($path, $data);
}
Solved using NULL as separator:
foreach($files as $file)
{
$content = Storage::get($file);
Storage::append($tmp_file, $content, NULL);
}