Amazon S3 (Simple Storage Service) is one of the most reliable ways to store and serve files like images, videos, and documents.
In this tutorial, you’ll learn how to upload an image directly from the browser to your S3 bucket using JavaScript, while your .NET Core backend securely generates a pre-signed URL.
🧩 What Is a Pre-Signed URL?
A pre-signed URL is a temporary, secure URL generated by AWS SDK that allows you to upload (PUT) or download (GET) files directly from/to S3 without exposing your AWS credentials.
👉 Official AWS Docs: Pre-Signed URLs
🛠️ Prerequisites
Before starting, make sure you have:
An AWS account with S3 bucket access
An IAM user with
AmazonS3FullAccessor a custom policy that allows:{"Version": "2012-10-17","Statement": [ { "Effect": "Allow", "Action": ["s3:PutObject", "s3:GetObject"], "Resource": "arn:aws:s3:::your-bucket-name/*" }]}A .NET 6+ Web API project
A JavaScript (HTML) frontend
🧱 Step 1. Install AWS SDK in .NET Core
Install AWS SDK via NuGet:
dotnet add package AWSSDK.S3
⚙️ Step 2. Create Pre-Signed URL API in .NET Core
Here’s a working example controller to generate a pre-signed URL for S3 upload.
using Amazon.S3;
using Amazon.S3.Model;
using Microsoft.AspNetCore.Mvc;
using System;
namespace AwsUploadDemo.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class S3UploadController : ControllerBase
{
private readonly IAmazonS3 _s3Client;
private const string BucketName = "your-bucket-name";
public S3UploadController(IAmazonS3 s3Client)
{
_s3Client = s3Client;
}
[HttpGet("generate-url")]
public IActionResult GeneratePresignedUrl(string fileName)
{
var key = $"uploads/{Guid.NewGuid()}_{fileName}";
var request = new GetPreSignedUrlRequest
{
BucketName = BucketName,
Key = key,
Verb = HttpVerb.PUT,
Expires = DateTime.UtcNow.AddMinutes(10),
ContentType = "image/jpeg"
};
string presignedUrl = _s3Client.GetPreSignedURL(request);
return Ok(new
{
uploadUrl = presignedUrl,
fileUrl = $"https://{BucketName}.s3.amazonaws.com/{key}"
});
}
}
}
✅ What this does:
Generates a temporary URL valid for 10 minutes.
Allows HTTP PUT upload directly to S3.
Returns both the upload URL and the final public file URL.
🖼️ Step 3. Upload Image Using JavaScript (Frontend)
Create a simple index.html page with a file input and an upload button.

Join the conversation! Your thoughts help the community grow.