Posts

Showing posts with the label presigned urls

Uploading Files Safely to AWS S3 using Presigned URLs

Image
Introduction If you saw my previous post, I showed you how to upload files to AWS S3 using NodeJS, but that isn't actually the most efficient way to handle file uploads. The best way to handle secure file uploads to AWS S3 is by using Presigned URLs. How the process works: The Frontend requests an upload link from the server. NestJS generates a temporary, short-lived URL from AWS. The Frontend uses that URL to PUT the file directly to S3. This saves server resources because the file data doesn't have to pass through your backend. Prerequisites If you are new to AWS S3, please check out my previous posts. You’ll need to understand the basics, including how to set up your AWS Access Key ID, AWS Secret Access Key, and how to create an S3 Bucket before moving forward. Implementation Details First, install the NestJS CLI and create a new project: npm install -g @nestjs/cli nest new {project name} Create a .env file and add your AWS credentials: REGION = {REGION} ACCESS_KEY_ID ...