Skip to content

Instantly share code, notes, and snippets.

@arvindkumarbadwal
Last active July 14, 2020 10:15
Show Gist options
  • Save arvindkumarbadwal/fc7d25e839946e2b0d43460eb9970642 to your computer and use it in GitHub Desktop.
Save arvindkumarbadwal/fc7d25e839946e2b0d43460eb9970642 to your computer and use it in GitHub Desktop.
Laravel Storage File Copy From Public Disk To S3 Disk
<?php
/**
* Logic to copy public files to s3
*/
$sourceFiles = \Storage::disk('public')->allFiles();
$destinationFiles = \Storage::disk('s3')->allFiles();
foreach ($sourceFiles as $file) {
if (!in_array($file, $destinationFiles)) {
$content = \Storage::disk('public')->get($file);
\Storage::disk('s3')->put($file, $content);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment