feat: Implement Secure R2 Storage with Private Bucket and Proxy Controller

This commit is contained in:
dyzulk
2026-01-04 18:07:22 +07:00
parent b4ea949bf2
commit 4dc4b3d498
5 changed files with 102 additions and 7 deletions

View File

@@ -82,12 +82,12 @@ class TicketController extends Controller
// Handle Attachments
if ($request->hasFile('attachments')) {
foreach ($request->file('attachments') as $file) {
$path = $file->store('ticket-attachments', 'r2');
$url = Storage::disk('r2')->url($path);
$path = $file->store('ticket-attachments', 'r2-private');
// $url = Storage::disk('r2')->url($path); // Removed public URL generation
TicketAttachment::create([
'ticket_reply_id' => $reply->id,
'file_name' => $file->getClientOriginalName(),
'file_path' => $url,
'file_path' => $path, // Store relative path
'file_type' => $file->getClientMimeType(),
'file_size' => $file->getSize(),
]);
@@ -170,12 +170,12 @@ class TicketController extends Controller
// Handle Attachments
if ($request->hasFile('attachments')) {
foreach ($request->file('attachments') as $file) {
$path = $file->store('ticket-attachments', 'r2');
$url = Storage::disk('r2')->url($path);
$path = $file->store('ticket-attachments', 'r2-private');
// $url = Storage::disk('r2')->url($path);
TicketAttachment::create([
'ticket_reply_id' => $reply->id,
'file_name' => $file->getClientOriginalName(),
'file_path' => $url,
'file_path' => $path, // Store relative path
'file_type' => $file->getClientMimeType(),
'file_size' => $file->getSize(),
]);