Skip to content

Commit

Permalink
iCreate proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1DEA committed Sep 16, 2024
1 parent 164ee5e commit 8052eb1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/Http/Controllers/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class DownloadController extends Controller
{
public function __invoke(string $id): Response|RedirectResponse
public function __invoke(string $id)//: Response|RedirectResponse
{
$hashids = new Hashids(bin2hex(Crypt::getKey()), 8);
$result = $hashids->decode($id);
Expand All @@ -26,8 +26,17 @@ public function __invoke(string $id): Response|RedirectResponse
$media->save();
})->afterResponse();

return redirect(Storage::disk('contabo')->temporaryUrl($media->path, now()->addMinutes(5), [
$object_url = Storage::disk('contabo')->temporaryUrl($media->path, now()->addMinutes(5), [
'ResponseContentDisposition' => 'attachment;filename=' . $media->filename
]));
]);

if (request()->string('__PROXY')->toString() === 'THIS_IS_A_TEMPORARY_SOLUTION') {
return response(Storage::disk('contabo')->get($media->path), 200, $headers = [
'Content-type' => 'application/octet-stream',
'Content-Disposition' => 'attachment; filename="' . $media->filename . '"',
]);
}

return redirect($object_url);
}
}
7 changes: 7 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@
});
});

Route::get('chkdsk', function () {
// todo: other disks potentially
if (request()->string('disk')->toString() !== 'contabo-usc1') return response('storage disk not found', 404);

return redirect(Storage::disk('contabo')->temporaryUrl('hello.txt', now()->addWeek()));
});

$fix_style = function (\App\Models\Forge\Style $style) {
$sizes = [
'sd' => null,
Expand Down

0 comments on commit 8052eb1

Please sign in to comment.