Skip to content

feat(storage): add PUT method support for getUrl presigned upload URLs#14740

Open
osama-rizk wants to merge 5 commits intomainfrom
feat/pre-signed-upload-url
Open

feat(storage): add PUT method support for getUrl presigned upload URLs#14740
osama-rizk wants to merge 5 commits intomainfrom
feat/pre-signed-upload-url

Conversation

@osama-rizk
Copy link
Contributor

Description of changes

This PR adds support for generating presigned URLs for file uploads to S3 by introducing a new method option to the getUrl API.

Key Changes:

  • Add method?: 'GET' | 'PUT' option to GetUrlOptions (defaults to 'GET' for backward compatibility)
  • Implement getPresignedPutObjectUrl function for PUT operations
  • Skip object existence validation for PUT operations (since object doesn't exist yet)
  • Add test coverage for all new functionality

Usage:

import { getUrl } from 'aws-amplify/storage';

// Generate presigned URL for file upload
const { url } = await getUrl({
 path: 'photos/vacation.jpg',
 options: {
   method: 'PUT',
   contentType: 'image/jpeg',
   expiresIn: 3600
 }
});

// Use the URL to upload file directly to S3
await fetch(url, {
 method: 'PUT',
 body: file,
 headers: { 'Content-Type': 'image/jpeg' }
});

Issue #, if available

Closes #14111
Related to aws-amplify/learn#450

Description of how you validated changes

  1. Unit Testing: Ran yarn test locally and verified all tests pass, including:

    • New tests for getPresignedPutObjectUrl function
    • Updated tests for getUrl API with PUT method support
    • Tests covering validation skipping, content headers, and parameter passing
    • Both key-based and path-based operations
  2. Manual Testing: Linked the changes to a sample application and verified:

    • Successfully generated presigned PUT URLs
    • Uploaded files directly to S3 using the presigned URLs
    • Confirmed files appeared in the connected S3 bucket

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@osama-rizk osama-rizk requested review from a team, avi-karthik, pranavosu and sarayev as code owners March 3, 2026 15:58
@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: ca13404

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@osama-rizk osama-rizk force-pushed the feat/pre-signed-upload-url branch from 4475294 to 6d5173c Compare March 3, 2026 15:59
@osama-rizk osama-rizk requested a review from a team as a code owner March 4, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

upload from file using presigned URL in amplify gen2

1 participant