diff --git a/app/Http/Controllers/AlbumController.php b/app/Http/Controllers/AlbumController.php index f00d0a8..f0c6152 100644 --- a/app/Http/Controllers/AlbumController.php +++ b/app/Http/Controllers/AlbumController.php @@ -109,6 +109,19 @@ public function store(Request $request) return redirect(route("album.index"))->with(["message" => "Photo ajouté avec success"]); } + public function update(Request $request, string $id) + { + $request->validate([ + "name" => "required|string|max:255", + ]); + $album = Album::where("uuid", $request->id)->first(); + if(!$album) redirect()->back()->withErrors(["uuid" => "Album introuvable" ]); + $album->update([ + "name" => $request->name + ]); + return redirect(route("album.index"))->with(["message" => "Album modifié avec success"]); + } + public function addPhotos(Request $request) { $album = Album::where("uuid", $request->id)->first(); diff --git a/app/Http/Controllers/S3Controller.php b/app/Http/Controllers/S3Controller.php index f134bbc..92b5f15 100644 --- a/app/Http/Controllers/S3Controller.php +++ b/app/Http/Controllers/S3Controller.php @@ -98,8 +98,20 @@ public function ProxyS3(Request $request) public function Download(Request $request) { - $url = S3::signUrl($request->key); - return redirect($url); + if(!$request->key) return redirect()->back()->withErrors("error", "Aucun fichier a été télécharger."); + $url = $request->key; + $filename = pathinfo($request->key, PATHINFO_BASENAME); + if(!Storage::disk("s3")->exists($url)) return redirect()->back()->withErrors("error", "Fichier introuvable."); + $path = pathinfo($url, PATHINFO_DIRNAME); + return response()->streamDownload(function() use ($url) { + $stream = Storage::disk('s3')->readStream($url); + while (!feof($stream)) { + echo fread($stream, 256 * 1024); + flush(); + } + fclose($stream); + }, $filename, ['Cache-Control' => "max-age=86400" ]); } + } diff --git a/app/Models/Album.php b/app/Models/Album.php index 677aa5f..b9f2d59 100644 --- a/app/Models/Album.php +++ b/app/Models/Album.php @@ -20,7 +20,7 @@ public function jsonSerialize():array 'uuid' => $this->uuid, 'name' => $this->name, 'path' => $this->path, - 'image' => S3::signUrl($this->path), + 'image' => $this->path, 'user' => $this->user, 'created_at' => date("d.m.Y", strtotime($this->created_at)), ]; diff --git a/app/Models/Photo.php b/app/Models/Photo.php index bf487b6..379c25f 100644 --- a/app/Models/Photo.php +++ b/app/Models/Photo.php @@ -20,7 +20,7 @@ public function jsonSerialize():array return [ 'uuid' => $this->uuid, 'name' => $this->name, - 'path' => S3::signUrl($this->path), + 'path' => $this->path, 'user' => $this->user, 'created_at' => date("d.m.Y", strtotime($this->created_at)), ]; diff --git a/resources/js/Pages/Album/Partials/Edit.vue b/resources/js/Pages/Album/Partials/Edit.vue index b23ef80..1cdacd3 100644 --- a/resources/js/Pages/Album/Partials/Edit.vue +++ b/resources/js/Pages/Album/Partials/Edit.vue @@ -1,5 +1,6 @@ \ No newline at end of file diff --git a/resources/js/Pages/Album/Partials/Show.vue b/resources/js/Pages/Album/Partials/Show.vue index 9806a76..d584d2a 100644 --- a/resources/js/Pages/Album/Partials/Show.vue +++ b/resources/js/Pages/Album/Partials/Show.vue @@ -42,6 +42,7 @@ const deleteAlbum = async (e) => { \ No newline at end of file diff --git a/resources/js/Pages/Photo/Partials/Modal.vue b/resources/js/Pages/Photo/Partials/Modal.vue index efca67a..1ad8a21 100644 --- a/resources/js/Pages/Photo/Partials/Modal.vue +++ b/resources/js/Pages/Photo/Partials/Modal.vue @@ -1,4 +1,5 @@