File uploading

File uploading

This guide walks you through setting up file uploads in your SaaS.


  • AWS S3 with presigned URLs — secure, scalable storage; ideal for growing apps. (Recommended)
  • Multer (server uploads) — send files to your server via middleware; fine for small files and low scale.

Which to choose?

Go with S3 + presigned URLs if you want durability, security, and room to grow.

If you only need occasional, small uploads and don’t expect big scale, Multer on your server is enough.


Using AWS S3

How presigned URLs work:

  1. Client asks the server for permission to upload a file
  2. Server generates a time-limited presigned URL using its AWS credentials
  3. Server returns that URL to the client
  4. Client uploads directly to S3 with the presigned URL before it expires

This keeps your AWS credentials on the server and avoids piping file data through your app server.

Create an AWS account

Create a root account, then create an IAM user for your app. Follow an external guide that walks through IAM users and S3 buckets.

Create an S3 bucket:

  1. Navigate to the S3 service in the AWS console preview
  2. Click Create bucket preview
  3. Enter bucket name and region
  4. Leave other settings at defaults, then click Create bucket preview

Change the CORS settings:

  1. Open the bucket you just created preview
  2. Go to the Permissions tab preview
  3. Scroll to Cross-origin resource sharing (CORS) and click Edit preview
  4. Paste the config below and click Save changes. Update AllowedOrigins to fit your app. Include http://localhost:3000 for local development and https://<your-domain> for production. If you do not have a domain yet, keep only localhost and add your domain later before production.
CORS Configuration
[
  {
   "AllowedHeaders": ["*"],
   "AllowedMethods": ["POST", "GET"],
   "AllowedOrigins": [
    "http://localhost:3000",
    "https://"
   ],
   "ExposeHeaders": []
  }
]

Get your AWS S3 credentials:

  1. Click your username in the top right of the AWS console and open Security credentials preview
  2. Scroll to Access keys
  3. Click Create access key
  4. Choose Application running on an AWS service and create the key preview
  5. Copy the Access key ID and Secret access key into src/app/.env.server:
.env.server
AWS_S3_IAM_ACCESS_KEY=ACK...
AWS_S3_IAM_SECRET_KEY=t+33a...
AWS_S3_FILES_BUCKET=your-bucket-name
AWS_S3_REGION=your-region // (e.g. us-west-2)

[Content continues in next part due to length…]