I am using Laravel's Storage
facade to access an AWS s3 bucket (with league/flysystem-aws-s3-v3
), and am looking for an efficient way to replace a given file's first line.
The files I'm working with are always non-empty CSVs, and can be up to gigabytes - hence why I'm looking for a solution that doesn't require me to first download, and then re-upload, the entire file.
I have tried the following, but I feel there must be a more efficient way.
$original = Storage::get($path);
$lines = explode(PHP_EOL, $original);
$lines[0] = $someString;
$replacement = implode(PHP_EOL, $lines);
Storage::put($path, $replacement);
A solution that simply deletes the first line is also very much appreciated - I can use that along with Storage::prepend()
to achieve the same result.
Thanks in advance.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ubuk0Z
via IFTTT
Aucun commentaire:
Enregistrer un commentaire