Have you used AWS S3?
AWS S3 Document Upload & Download — Steps
Step 1: AWS S3 Setup
- Create S3 bucket: bucket-name
- Region: us-east-1
- Block public access ✅
- Create IAM user with AmazonS3FullAccess → get Access & Secret Key
Step 2: Add Dependencies (Spring Boot)
- E.g., software.amazon.awssdk:s3
Step 3: application.yml
aws:
s3:
bucket-name: your-bucket
region: us-east-1
access-key: YOUR_ACCESS_KEY
secret-key: YOUR_SECRET_KEY
Step 4: S3 Configuration Class
- Create S3Client bean with credentials
Step 5: S3 Service (Core Logic)
- uploadFile(MultipartFile file) → uploads to S3
- downloadFile(String fileName) → downloads from S3
Step 6: REST Controller
@PostMapping(“/upload”)
public ResponseEntity<String> upload(@RequestParam(“file”) MultipartFile file)
@GetMapping(“/download/{fileName}”)
public ResponseEntity<byte[]> download(@PathVariable String fileName)
Step 7: Store in Database (File URL)
- After uploading to S3, save the file key or URL in DB
Step 8: React Example
Get Wablepratiksha’s stories in your inbox
Join Medium for free to get updates from this writer.
await fetch(“http://localhost:8080/api/files/upload", {
method: “POST”,
body: formData,
});
Normal Flow (Backend uploads file to S3)
- Backend uploads file to S3 → S3 returns file key or URL
- You store file name / key / S3 URL in DB
Pre-Signed URL Flow (Frontend uploads directly to S3)
- Backend generates pre-signed URL → frontend uploads file directly
- After upload, you store file name or final S3 URL in DB




