iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Give the browser a short-lived presigned S3 URL, never an AWS access key. Your server checks who the user is, chooses the object key, and signs a single PUT for that key. The browser then uploads the file straight to S3 using that URL. The user gets permission for that one operation and nothing else: no bucket listing, no reads of other objects, and no writes to other keys.
This tutorial walks through the trust boundary, a working server and browser pair, the CORS rules a browser upload needs, and the checks to run before you accept a file. The AWS pages behind this guide were checked in October 2026 and do not show publication dates, so confirm current SDK method names and console labels against AWS’s own documentation before you ship.
Where the trust boundary sits
The application server is the only party that holds AWS authority. It runs under an IAM role or other temporary credentials, and it uses them to create a presigned URL. AWS documents that a presigned URL performs its operation with the permissions of the principal that created it, so the URL is only as strong as the server’s own permissions. A URL signed by a role that can write to uploads/* can write only there.
What the browser receives is a capability, not an identity. AWS describes presigned URLs this way in the Amazon S3 User Guide: “In essence, presigned URLs are bearer tokens that grant access to those who possess them.” That means anyone who obtains the URL can use it until it expires, and it can be used more than once. It also means the URL must be treated as a secret.
#1 Best Overall
- USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
- Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
- Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
- Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
- Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty
- The browser can send one signed HTTP request to S3 for the key and method you specified.
- The browser cannot list the bucket, read other objects, or change bucket settings.
- The browser never sees an access key ID or secret access key.
- If the signing credentials are revoked or expire, the URL stops working even if its own expiry time has not arrived.
The upload flow, step by step
- Authenticate and authorize on the server. Confirm the user is signed in and allowed to upload in the current context, such as a particular project or account. Reject the request before any URL is generated.
- Validate the declared metadata. Check the requested content type and, if you collect it, the file size against an allowlist you control. Treat these values as claims from the client, not facts.
- Choose the object key on the server. Build a key such as
uploads/{user_id}/{random_uuid}. Never accept a path from the client. Store the key with the upload record so you can find the object later. - Sign one operation with a short expiry. Sign
put_objectfor that bucket, key, and content type. Five minutes is enough for most browser uploads; the AWS SDK example in the next section uses 300 seconds. - Return the URL and the required headers. Send the URL and the exact
Content-Typevalue to the browser. Do not write the URL to application logs or analytics events. - Upload from the browser with PUT. The browser sends the file body directly to S3 using the same method and content type that were signed.
- Verify and accept the object. When the browser reports success, have your server confirm the object exists, check its size and type, and only then link it to the user’s record. This last step is an application design recommendation; AWS’s pages describe the signing mechanics, not your business workflow.
Try it: the server side
The example below uses Python with boto3. It creates a signed PUT URL for one object. Replace BUCKET and the region with your own values, and use the bucket’s actual region, because a wrong region is a common cause of signature errors.
Generate the presigned URL
import uuid
import boto3
from botocore.config import Config
BUCKET = "your-private-upload-bucket"
REGION = "eu-west-1"
ALLOWED_TYPES = {"image/png", "image/jpeg", "application/pdf"}
s3 = boto3.client(
"s3",
region_name=REGION,
config=Config(signature_version="s3v4"),
)
def create_upload_grant(user_id: str, content_type: str) -> dict:
if content_type not in ALLOWED_TYPES:
raise ValueError("File type not allowed")
# The server chooses the key. The client never supplies a path.
key = f"uploads/{user_id}/{uuid.uuid4()}"
url = s3.generate_presigned_url(
ClientMethod="put_object",
Params={
"Bucket": BUCKET,
"Key": key,
"ContentType": content_type,
},
ExpiresIn=300, # seconds
HttpMethod="PUT",
)
return {"url": url, "key": key, "content_type": content_type}
Your application must also save the returned key against the user’s upload record before it sends the grant to the browser. Without that record, you cannot later decide which objects belong to whom.
Rank #2
- High-speed USB 3.0 performance of up to 150MB/s(1) [(1) Write to drive up to 15x faster than standard USB 2.0 drives (4MB/s); varies by drive capacity. Up to 150MB/s read speed. USB 3.0 port required. Based on internal testing; performance may be lower depending on host device, usage conditions, and other factors; 1MB=1,000,000 bytes]
- Transfer a full-length movie in less than 30 seconds(2) [(2) Based on 1.2GB MPEG-4 video transfer with USB 3.0 host device. Results may vary based on host device, file attributes and other factors]
- Transfer to drive up to 15 times faster than standard USB 2.0 drives(1)
- Sleek, durable metal casing
- Easy-to-use password protection for your private files(3) [(3)Password protection uses 128-bit AES encryption and is supported by Windows 7, Windows 8, Windows 10, and Mac OS X v10.9 plus; Software download required for Mac, visit the SanDisk SecureAccess support page]
Upload from the browser
async function uploadFile(file, grant) {
const response = await fetch(grant.url, {
method: "PUT",
headers: { "Content-Type": grant.content_type },
body: file,
});
if (!response.ok) {
throw new Error("Upload failed with status " + response.status);
}
return grant.key;
}
The Content-Type header must match the value you signed. Use the value the server returned, not whatever file.type reports at upload time, unless your server checked that they are identical.
Confirm the object landed
From a terminal with read access to the bucket, check that the object exists and has the size you expect:
Rank #3
- What You Get - 2 pack 64GB genuine USB 2.0 flash drives, 12-month warranty and lifetime friendly customer service
- Great for All Ages and Purposes – the thumb drives are suitable for storing digital data for school, business or daily usage. Apply to data storage of music, photos, movies and other files
- Easy to Use - Plug and play USB memory stick, no need to install any software. Support Windows 7 / 8 / 10 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, compatible with USB 2.0 and 1.1 ports
- Convenient Design - 360°metal swivel cap with matt surface and ring designed zip drive can protect USB connector, avoid to leave your fingerprint and easily attach to your key chain to avoid from losing and for easy carrying
- Brand Yourself - Brand the flash drive with your company's name and provide company's overview, policies, etc. to the newly joined employees or your customers
aws s3api head-object --bucket your-private-upload-bucket --key "uploads/USER_ID/UUID"
A successful response returns metadata such as ContentLength and ContentType. If you get a 404, the upload did not complete or the key differs from the one you stored.
Configure bucket CORS for the browser
CORS applies when the page is served from one origin, such as https://app.example.com, and the request goes to S3 at a different origin. The Amazon S3 User Guide describes this as a way for “client web applications that are loaded in one domain to interact with resources in a different domain.” CORS only decides whether the browser may make the cross-origin request. The signature and IAM permissions still decide whether S3 performs the operation.
Rank #4
- GOOD VALUE PACKAGE - 1 Pack 32GB Memory Stick USB 2.0 Flash Drives with great cost performance and high quality.
- BIG CAPACITY - The available capacity: 29.10GB-29.8GB, You can save the data of movies, music, photos, designs, programs, manuals, handouts in a high speed.Good performance in digital data storing, transferring and sharing with families, friends, workmates, clients and machines.
- EASY TO USE & PLUG AND WORK - Support windows 7 / 8 / 10 / Vista / XP / 2000 / ME / NT Linux and Mac OS, Compatible with USB2.0 and below.
- TWISTTURN DESIGN & EASY CARRY - The metal clip rotates 360° round the ABS plastic body which with rubber oil skin feeling finish. The capless design can avoid lossing of cap, and providing efficient protection to the USB port.
- WARRANTY & SUPPORT - SIMMAX logo is laser printed on the USB connector surface, our products are of good quality and we promise that any problem about the product within one year since you buy.
Add a rule like this in the bucket’s CORS configuration (S3 console: bucket, then Permissions, then Cross-origin resource sharing). Use your exact site origin, including the scheme, and list only what the browser sends:
Free tools Windows power users keep installed
One-click scans. No signup required.
[
{
"AllowedOrigins": ["https://app.example.com"],
"AllowedMethods": ["PUT"],
"AllowedHeaders": ["Content-Type"],
"ExposeHeaders": ["ETag"],
"MaxAgeSeconds": 3000
}
]
Keep ExposeHeaders only if your code reads a response header. Avoid "*" for origins on a bucket that holds user files; a wildcard lets any website script the upload flow in a visitor’s browser.
Best Value
- 【16GB Flash Drive】USB flash drives with 16GB capacity, meet your needs of daily use on work, school, home and travelling for photos, music, videos, files storage and transfer. IMEASON thumb drives can be used to store different files, easy to data backup.
- 【Metal Swivel Cap Design】USB thumb drive is metal swivel cover provides extra protection for the usb thumbdrive connector, no usb drive cap to lose; keychain design makes it easier to carry without worrying lose it.
- 【Wide Compatibility】USB drive supports Windows 7/8/10/11 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, also Supports USB 2.0 and 1.1 ports. USB Stick support TV, desktop, notebook computer, car, audio and other device. The USB Memory Stick is your great data storage and transfer companion with traveling and working.
- 【Easy to use】usb memory stick is plug and play without any software installation. Just simply plug the Flashdrive into the port of your USB-compatible devices such as computer, laptop to start data storage or transmission.
- 【What You Get】16 GB USB Flash Drive Thumb Drive, The default format of the usb storage flash drive is FAT32.
PUT or POST: which signed browser flow to use
AWS documents two browser-based approaches. A presigned PUT is a single signed request with the file as the body. A signed POST is a multipart HTML form with a base64-encoded policy and SigV4 fields that constrain what the upload may contain. The choice is about fit, not strength: both depend on server-side authorization, a private bucket, safe key selection, and protection of the issued capability.
| Axis | Presigned PUT | Signed browser POST |
|---|---|---|
| Browser request | An HTTP PUT with the file as the request body, sent to the signed URL. | A multipart/form-data form submitted to the bucket endpoint. |
| What is signed | The bucket, key, content type, and expiry in the AWS SDK example used here. | A policy document with conditions, plus SigV4 form fields. |
| Constraining the upload | Limited to the signed operation and headers; a different key or content type fails the signature check. | Conditions in the policy can limit key prefix, content type, and size, as the form policy defines them. |
| Fit | Simple code path for JavaScript fetch or XHR uploads. | Useful when your workflow already uses native form submission or form-policy conditions. |
| CORS | Needs a CORS rule for the page origin, PUT, and the headers sent. | Needs a CORS rule that matches the form’s origin and method; verify against the exact request. |
Unless you have a specific reason to build a form, the PUT flow above is the shorter path to a working upload.
Quick Recap
Security rules that decide whether this is safe
- Keep the bucket private. Presigned uploads do not require a publicly writable bucket. AWS’s signed POST documentation notes that requests without the required authentication policy are anonymous and succeed only on a publicly writable bucket. Do not open the bucket to solve an upload problem.
- Use an IAM role for the backend. AWS’s S3 security best practices recommend IAM roles and temporary credentials for applications rather than long-term keys in code or on instances. Grant the role
s3:PutObjectonly on the upload prefix it needs. - Keep expiry short and understand the ceiling. AWS documents that URLs created with the CLI or SDK can be configured for up to seven days. That is a product limit, not a recommendation for user uploads. Temporary credentials can also end the URL’s life early, so a long
ExpiresIndoes not guarantee a long-lived URL. - Generate unique keys. Uploading to an existing key replaces the object. Random server-side keys prevent one user from overwriting another’s file or a previous upload.
- Enforce HTTPS. AWS recommends using the
aws:SecureTransportcondition in bucket policies so that requests without TLS are denied. - Do not treat the signature as content validation. A valid presigned URL does not check malware, real file type, or actual size. Check those on the server after upload, and scan with the tooling your threat model calls for. A file extension or a CORS rule is not validation.
- Consider recovery controls. Default server-side encryption applies to new objects, and S3 Versioning preserves earlier object variants so an accidental overwrite can be recovered. These are bucket settings you can enable independently of presigning.
Troubleshooting failed uploads
| Symptom | Likely cause | Fix |
|---|---|---|
SignatureDoesNotMatch |
Clock skew, a modified URL, an expired URL, a Content-Type that differs from the signed value, or the wrong region. | Synchronize system time; use the generated URL without changes; regenerate if it has expired; send the exact signed Content-Type; use the bucket’s region. |
| Browser shows a CORS error, but the same request works with curl | The OPTIONS preflight is rejected because the origin, method, or requested header is not in the CORS rule. | Add the exact page origin, PUT, and any header the browser sends, such as Content-Type. Test from the deployed origin. |
AccessDenied when the URL is used |
The signing role lacks permission for that action on that bucket or prefix, or the credentials that signed the URL have since expired. | Grant s3:PutObject on the upload prefix to the signing role and generate a new URL. |
| An existing file was replaced | The key was reused, and S3 overwrote the object. | Generate keys with a random component on the server; enable Versioning if overwrites must be recoverable. |
Where to verify the details
- AWS, “Download and upload objects with presigned URLs” in the Amazon S3 User Guide, for permissions, reuse, overwrite behavior, and expiry rules.
- AWS, “Uploading objects with presigned URLs” in the Amazon S3 User Guide, for the SDK example and signature troubleshooting.
- AWS, “Using cross-origin resource sharing (CORS)” in the Amazon S3 User Guide, for rule matching.
- AWS, “Creating an HTML Form (Using AWS Signature Version 4)”, for signed POST fields.
- AWS, “Security best practices for Amazon S3”, for IAM roles, encryption, TLS, and versioning.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

