<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hassan / laravel-s3-browser-based-uploads example snippets
use Hassan\S3BrowserBasedUploads\Facades\S3BrowserBasedUploads;
// Get the S3 endpoint URL
$endpointUrl = S3BrowserBasedUploads::getEndpointUrl();
// Get the presigned POST fields
$fields = S3BrowserBasedUploads::getFields();
// Use a different connection
$fields = S3BrowserBasedUploads::connection('secure_images')->getFields();
// In your RouteServiceProvider or routes/web.php
use Hassan\S3BrowserBasedUploads\S3BrowserBasedUploads;
public function boot()
{
// Registers GET route: /s3_browser_based_uploads/credentials
S3BrowserBasedUploads::routes();
// With custom options (e.g., authentication middleware)
S3BrowserBasedUploads::routes([
'middleware' => ['auth', 'throttle:60,1'],
'prefix' => 'api/uploads',
]);
}
// In your backend before generating credentials
'key' => 'uploads/' . Str::uuid() . '.' . $extension
['content-length-range', 1, 10485760] // 1 byte to 10MB
['starts-with', '$Content-Type', 'image/'] // Images only
['eq', '$Content-Type', 'application/pdf'] // PDFs only