Update Avatar pipeline, fix cloud storage media_path

pull/3879/head
Daniel Supernault 2022-12-02 02:45:35 -07:00
rodzic 9a89a2b751
commit 02edd19d4d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 0DEF1C662C9033F7
3 zmienionych plików z 5 dodań i 4 usunięć

Wyświetl plik

@ -196,8 +196,8 @@ class AvatarStorage extends Command
continue;
}
$newMediaPath = $disk->put($newPath, $existing);
$avatar->media_path = $newMediaPath;
$avatar->cdn_url = $disk->url($newMediaPath);
$avatar->media_path = $newPath;
$avatar->cdn_url = $disk->url($newPath);
$avatar->save();
}

Wyświetl plik

@ -93,8 +93,9 @@ class AvatarOptimize implements ShouldQueue
$base = 'cache/avatars/' . $avatar->profile_id;
$disk = Storage::disk(config('filesystems.cloud'));
$disk->deleteDirectory($base);
$path = $base . '/' . 'a' . strtolower(Str::random(random_int(3,6))) . $avatar->change_count . '.' . pathinfo($avatar->media_path, PATHINFO_EXTENSION);
$path = $base . '/' . 'avatar_' . strtolower(Str::random(random_int(3,6))) . $avatar->change_count . '.' . pathinfo($avatar->media_path, PATHINFO_EXTENSION);
$url = $disk->put($path, Storage::get($avatar->media_path));
$avatar->media_path = $path;
$avatar->cdn_url = $disk->url($path);
$avatar->save();
Storage::delete($avatar->media_path);

Wyświetl plik

@ -229,7 +229,7 @@ class MediaStorageService {
$base = ($local ? 'public/cache/' : 'cache/') . 'avatars/' . $avatar->profile_id;
$ext = $head['mime'] == 'image/jpeg' ? 'jpg' : 'png';
$path = Str::random(20) . '_avatar.' . $ext;
$path = 'avatar_' . strtolower(Str::random(random_int(3,6))) . '.' . $ext;
$tmpBase = storage_path('app/remcache/');
$tmpPath = 'avatar_' . $avatar->profile_id . '-' . $path;
$tmpName = $tmpBase . $tmpPath;