How to get public URL after uploading image to S3?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Amazon S3 (Simple Storage Service) is a widely used service for storing and retrieving any amount of data at any time. One common use case is uploading images and making them accessible via a public URL. This article provides a comprehensive guide on how to achieve that, with additional information and examples to facilitate the process.
Prerequisites
Before commencing, ensure you have the following:
- AWS Account: You need an account with AWS.
- S3 Bucket: A pre-configured bucket in AWS S3.
- AWS CLI or SDK: Useful for AWS operations programmatically.
- Permissions: Adequate IAM permissions for uploading and configuring files.
Steps to Upload an Image and Get a Public URL
Step 1: Upload Image to S3
Using AWS Management Console
- Log in to your AWS console.
- Navigate to `S3`.
- Select your target bucket.
- Click on `Upload`.
- Select the image file to upload.
- Configure permissions. For a public URL, you can set it to `Grant public-read access`.
- Complete the upload process.
Using AWS CLI
Install AWS CLI and configure it if not done:
- ACL (Access Control List): Defines who can access resources within your bucket. `public-read` access is crucial for allowing public URL access.
- Bucket Policy: Can be used to set permissions at the bucket level rather than individual objects.
- Public Access: Making a file publicly accessible can expose it to anyone with the URL, so this should be done with caution.
- Permissions: Use IAM policies and roles for secure access management.
- Bucket Policies: Apply bucket-level restrictions if strict control is required over object permissions.
- AWS SDKs: Available for various languages (Java, Python, JavaScript, etc.), these SDKs can automate many S3 operations.
- AWS IAM: Configuring users and permissions is vital for secure access to S3 resources.
Related reading
- how to get return response from AWS Lambda function
- How to Get Signed S3 Url in AWS-SDK JS Version 3?
- How to get the instance Name from the instance in AWS?
- How to get the region of the current user from boto?
- How to get the table name in AWS dynamodb trigger function?
- How to get the URL of a file on AWS S3 using aws-sdk?
- How to get the user's canonical ID for adding a S3 permission
- How to get total number of pages in DynamoDB if we set a limit?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.