Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Arya_Svitkona's avatar

Store medium sized files via REST API deployed via Vapor on AWS.

Dear community,

I just learned, that due to Lambda limitations by AWS, we are not allowed to submit larger files than 4.5MB Source. How can we store bigger files (like 10MB or sometimes 100MB) without using the npm laravel-vapor package, since our application is a REST API?

Do we have to use presigned urls, which we have to provide to the client? Is that the really only way?

0 likes
2 replies
LaryAI's avatar
Level 58

To handle larger file uploads in a REST API deployed on AWS Lambda via Laravel Vapor, you can indeed use presigned URLs. This is a common approach to bypass the Lambda size limitations by allowing clients to upload files directly to S3. Here's how you can implement this solution:

Step-by-Step Solution

  1. Generate a Presigned URL: You can generate a presigned URL on your server, which the client can use to upload files directly to S3. This URL will allow the client to upload a file without needing to go through your server, thus bypassing the Lambda size limitation.

  2. Set Up AWS SDK: Ensure you have the AWS SDK set up in your Laravel application. You can use the aws/aws-sdk-php package, which is typically included with Laravel Vapor.

  3. Create a Controller Method: Create a method in your controller to generate the presigned URL. Here’s an example:

  4. Client-Side Upload: On the client side, use the presigned URL to upload the file directly to S3. Here’s an example using JavaScript:

    async function uploadFile(file) {
        const response = await fetch('/api/generate-presigned-url', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                file_name: file.name,
                file_type: file.type,
            }),
        });
    
        const { url } = await response.json();
    
        await fetch(url, {
            method: 'PUT',
            headers: {
                'Content-Type': file.type,
            },
            body: file,
        });
    
        console.log('File uploaded successfully');
    }
    
  5. Security Considerations:

    • Ensure that the presigned URL generation endpoint is secure and only accessible to authenticated users.
    • Consider setting appropriate permissions and expiration times for the presigned URLs to prevent unauthorized access.

By using presigned URLs, you can efficiently handle large file uploads in your REST API without being constrained by AWS Lambda's size limitations.

Arya_Svitkona's avatar

Right now we don't have a solution for bigger files, but as far as we know the limiting factor would be the API Gateway. The API Gateway will collect the "full request" and forward it to the lambda, which can be max. 10MB as my colleague told me.

So streaming the file from client to the lambda is not possible.

Looks like we have to change our hosting or get along with presigned urls.

Please or to participate in this conversation.