Skip to content

Instantly share code, notes, and snippets.

@AdelinGhanaem
Created May 18, 2022 16:52
Show Gist options
  • Select an option

  • Save AdelinGhanaem/358abe5447eb30c9880d2a9ed5dfafa6 to your computer and use it in GitHub Desktop.

Select an option

Save AdelinGhanaem/358abe5447eb30c9880d2a9ed5dfafa6 to your computer and use it in GitHub Desktop.
function migrateImages() {
$ls = Storage::disk("s3")->allFiles("/prod");
foreach ($ls as $l) {
$newLoc = explode("/", $l);
if (sizeof($newLoc) == 4) {
Log::debug("=====> ".$l);
try {
Storage::disk("s3")->copy($l, "/" . $newLoc["0"] . "/" . $newLoc["1"] . "/" . $newLoc["2"] . "/big/" . $newLoc["4"]);
} catch (\Exception $e) {
Log::debug($e->getMessage());
}
try {
Storage::disk("s3")->copy($l, "/" . $newLoc["0"] . "/" . $newLoc["1"] . "/" . $newLoc["2"] . "/mid/" . $newLoc["4"]);
} catch (\Exception $e) {
Log::debug($e->getMessage());
}
try {
Storage::disk("s3")->copy($l, "/" . $newLoc["0"] . "/" . $newLoc["1"] . "/" . $newLoc["2"] . "/small/" . $newLoc["3"]);
} catch (\Exception $e) {
Log::debug($e->getMessage());
}
try {
Storage::disk("s3")->delete($l);
} catch (\Exception $e) {
Log::debug($e->getMessage());
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment