feat(storage): add server uploadData storage api#14796
Merged
osama-rizk merged 6 commits intomainfrom May 4, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 12af5cf The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
bobbor
reviewed
Apr 30, 2026
Member
bobbor
left a comment
There was a problem hiding this comment.
just some small nit. let me know what you think
Comment on lines
+23
to
+24
| * @throws An `S3Exception` when the underlying S3 service returned error. | ||
| * @throws A `StorageValidationErrorCode` when API call parameters are invalid. |
Member
There was a problem hiding this comment.
in JSDoc, the first paramter is the type.
@throws {ErrorType} Description of when this error is thrown.
Suggested change
| * @throws An `S3Exception` when the underlying S3 service returned error. | |
| * @throws A `StorageValidationErrorCode` when API call parameters are invalid. | |
| * @throws S3Exception when the underlying S3 service returned error. | |
| * @throws StorageValidationErrorCode when API call parameters are invalid. |
Contributor
Author
There was a problem hiding this comment.
JSDoc description updated ✅
| * @throws Service: `S3Exception` thrown when checking for existence of the object. | ||
| * @throws Validation: `StorageValidationErrorCode` thrown when a validation error occurs. | ||
| * @throws An `S3Exception` when the underlying S3 service returned error. | ||
| * @throws A `StorageValidationErrorCode` when API call parameters are invalid. |
bobbor
approved these changes
Apr 30, 2026
Contributor
|
Should we add/update E2E tests for this feature? |
soberm
approved these changes
May 4, 2026
Contributor
Author
Yes, E2E tests will be added as a follow up PR. |
This was referenced May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Adds a new server-side
uploadDataAPI for Storage, consumable in Next.js Server Components, Route Handlers, and Server Actions. Customers can now upload data directly from server contexts using the same Amplify server context pattern already used bylist,getProperties,getUrl,remove, andcopy.This addresses a long-standing customer request to upload files from a Next.js backend (tracked in #13636), which was previously only possible from the client. Enabling server-side upload unblocks common patterns where the file needs to be validated, transformed, or persisted together with database state on the server before being stored in S3.
Usage
Implementation approach
Rather than duplicating the upload pipeline, this PR refactors the existing internal
uploadDataimplementation to accept anAmplifyClassV6instance via dependency injection (first positional argument), eliminating its dependency on the globalAmplifysingleton. The existing client-side API, the advancedinternals/apis/uploadData, and the new server-side API all pass their respectiveAmplifyinstance to the same shared internal pipeline. This keeps multipart upload, checksum computation, cancellation, and progress reporting logic in a single place.Key changes
providers/s3/apis/internal/uploadData/*to acceptamplify: AmplifyClassV6as first parameter (removes implicit dependency on the globalAmplifysingleton).providers/s3/apis/server/uploadData.ts— thin wrapper that injectsgetAmplifyServerContext(contextSpec).amplifyinto the internal pipeline.providers/s3/apis/uploadData.tsto explicitly passAmplify.internals/apis/uploadData.tsto explicitly passAmplify.uploadDatafromproviders/s3/apis/server/index.ts; automatically flows through the existing@aws-amplify/storage/server→aws-amplify/storage/serverre-export chain.providers/s3/utils/readFile.tsto fall back toBlob.arrayBuffer()whenFileReaderis unavailable, so server-side uploads (which depend on this path for CRC32/MD5 checksum calculation on sliced parts) work under Node.js runtimes.Server-side behavior notes
resumableUploadsCache(used for pause/resume on the client) is intentionally NOT injected on the server path, since every server request runs in an isolated context and there is no consistent cross-request storage for upload state.task.pause()/task.resume()are gracefully handled as no-ops in this case (already supported bycreateUploadTask).Issue #, if available
Closes #13636
Description of how you validated changes
Unit tests
All 796 storage unit tests pass (
yarn testfrompackages/storage), including:internal/uploadData/index.test.ts(18 tests),internal/uploadData/putObjectJob.test.ts(19 tests),internal/uploadData/multipartHandlers.test.ts(93 tests),providers/s3/apis/uploadData.test.ts(client wrapper),internals/apis/uploadData.test.ts(advanced API) — all updated to pass an Amplify instance as first argument.providers/s3/apis/server/uploadData.test.ts— 4 tests covering path-based input, key-based input, verification thatresumableUploadsCacheis NOT injected server-side, and verification that the server context'samplify(not the global singleton) is used.providers/s3/utils/readFile.test.ts.Build
yarn buildinpackages/storagepasses with no type errors.Manual E2E validation in a Next.js 16 (App Router, Turbopack) sample app
uploadDatafrom@aws-amplify/storage/server— succeeded, single PutObject path.Checklist
yarn testpassesChecklist for repo maintainers
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.