When a prominent legal enterprise needed a custom portal to securely upload, transcode, and store massive evidentiary video files (often exceeding 50GB per file), standard web forms and basic API endpoints instantly timed out.
Furthermore, because the videos contained sensitive legal evidence, the architecture required strict SOC 2 compliance, end-to-end encryption, and comprehensive audit logging.
Here is how our backend engineering team at adronSoft utilized Laravel (PHP) and Cloudflare R2 to build a rock-solid, compliant video processing portal.
The Problem: PHP Memory Limits and Nginx Timeouts
Traditional HTTP POST uploads buffer the file into server memory or a temporary directory. If you try to upload a 50GB video, you will immediately hit upload_max_filesize, post_max_size, or Nginx client_max_body_size limits. Increasing these limits to 50GB is a massive security risk and practically invites DDoS attacks.
The Solution: Chunked Uploads & Direct-to-R2
We bypassed the Laravel server entirely for the actual data transfer. Instead, we implemented a Pre-Signed URL architecture utilizing Cloudflare R2.
1. Client-Side File Chunking (JavaScript)
On the frontend, we utilized the Resumable.js library to slice the massive video file into 5MB chunks in the browser. This ensures that if a user's internet connection drops after 45GB of uploading, they only have to retry the last 5MB chunk, not start over from zero.
2. Laravel Pre-Signed URL Generation
When the upload begins, the frontend makes an authenticated request to our Laravel API.
// Laravel Controller (Simplified)
public function getPresignedUrl(Request $request) {
// Cloudflare R2 uses the S3-compatible API
$s3 = Storage::disk('r2')->getClient();
$command = $s3->getCommand('PutObject', [
'Bucket' => env('R2_PRIVATE_BUCKET'),
'Key' => 'uploads/' . Auth::id() . '/' . Str::uuid() . '.mp4',
]);
$request = $s3->createPresignedRequest($command, '+20 minutes');
return response()->json([
'url' => (string) $request->getUri()
]);
}
Laravel generates a temporary, cryptographically signed R2 URL. The frontend then pushes the chunks directly to Cloudflare R2 using this URL, completely bypassing our PHP servers.
3. Zero Egress Fees with R2
Unlike AWS S3 which charges significant egress fees for streaming large video files to end-users, Cloudflare R2 has zero egress fees. By storing the high-volume payloads in R2 and placing them behind Cloudflare's massive global CDN network, we saved the client over $4,000/month in bandwidth costs while improving global playback latency.
Strict Enterprise Compliance & Security
Handling legal or healthcare (HIPAA) data requires more than just functional code. We implemented the following security layers:
- Temporary Access Tokens: When an authorized lawyer attempts to view the video, Laravel generates a signed CloudFront-style expiring URL that expires in exactly 5 minutes. If the URL is shared or leaked, it becomes useless almost instantly.
- Immutable Audit Logs: Every action—uploading, viewing, or deleting a video—triggers an Event in Laravel. We use an append-only database table to track the
user_id,IP_address,action, andtimestamp. This fulfills strict chain-of-custody requirements.
Why Laravel?
While Node.js or Go are often praised for stream handling, Laravel remains an absolute powerhouse for enterprise development. Its built-in queue workers (Horizon), robust Eloquent ORM, and elegant event broadcasting system allowed us to build the complex business logic (audit trails, granular RBAC permissions, compliance checks) in record time.
Need a custom, highly secure portal to handle complex workflows? Reach out to our engineering team to discuss architecture solutions tailored to your enterprise.