Repository navigation
Issue direct upload URLs from Cloud filesystems - #216
Open
brandonkelly wants to merge 5 commits into
Open
brandonkelly wants to merge 5 commits into
brandonkelly wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Compatibility and the MCP upload/claim flow still require validation against the upstream DirectUploadFsInterface, which is unavailable on Craft’s 5.x branch; the reported stub does not establish that contract.
No open issues 🎉
What changed in this PR
Adds direct S3 upload URLs to Cloud filesystems so Craft’s MCP uploads can bypass Lambda’s 6 MB request limit, while retaining the local-filesystem fallback.
Changes:
- Implements direct-upload support with URLs and required headers derived from a shared presigned request.
- Adds an interface shim for compatibility with older Craft versions.
- Adds unit tests for temporary-upload paths, signed metadata headers, and local-filesystem fallback.
| File | Description |
|---|---|
tests/unit/FsTest.php |
Tests direct-upload URLs, required headers, and local fallback. |
src/fs/Fs.php |
Implements direct-upload URL generation and shares presigning logic. |
src/fs/DirectUploadFsInterface.php |
Adds a compatibility shim for Craft’s direct-upload interface. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The unpublished Craft 5.13 upload-session contract requires human compatibility confirmation and end-to-end S3 validation that signed type/size mismatches are rejected and metadata survives finalization.
No open issues 🎉
Review effort: Balanced
Implement Craft's DirectUploadFsInterface (5.12.2+) on Fs, so Craft's MCP server can send files straight to S3 instead of through Lambda's 6 MB request limit. The interface is shimmed for older Craft versions. Amp-Thread-ID: https://ampcode.com/threads/T-54e734d2-d69f-42d7-9f3b-a6a8e281ad1d Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-54e734d2-d69f-42d7-9f3b-a6a8e281ad1d Co-authored-by: Amp <amp@ampcode.com>
Rename getDirectUploadUrl() to temporaryUploadUrl() to match Craft 5.13's interface, and sign Content-Type and Content-Length so storage rejects uploads of another type or size. The SDK leaves both unsigned by default. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e63f-d13c-70f3-bc1e-77416ea26a1e Co-authored-by: Amp <amp@ampcode.com>
- Name the object the way Flysystem does, so paths that need encoding aren't stored under a different key than Craft reads and deletes. - Return null when the URL can't be signed, so Craft falls back to receiving the file itself. - Only replace the SDK's signer for SigV4; other versions use the SDK's. - Ignore test logs. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e63f-d13c-70f3-bc1e-77416ea26a1e Co-authored-by: Amp <amp@ampcode.com>
timkelty
force-pushed
the
direct-upload-urls
branch
from
December 1, 2026 11:58
d4af09d to
6dd5f1c
Compare
Creating the upload client happened outside the try block, so a failure there escaped instead of returning null for Craft's transfer fallback. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e63f-d13c-70f3-bc1e-77416ea26a1e Co-authored-by: Amp <amp@ampcode.com>
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
Craft 5.13 is adding core upload sessions, so the control panel, front-end forms and MCP can upload files straight to storage. That gets around Lambda's 6 MB request limit. A filesystem opts in by implementing
craft\base\TemporaryUploadUrlInterface, and this PR implements it for Cloud's filesystems.Fs::temporaryUploadUrl($path, $expiresAt, $options)returns a presigned S3PutObjectURL, plus the headers the client must send: every signed header excepthost. It returns null underuseLocalFs, so Craft falls back to its own transfer endpoint.Content-TypeandContent-Length, from Craft'sContentTypeandContentLengthoptions. The AWS SDK leaves both unsigned by default, which would let a client upload any size, or store HTML under a.jpgname that the CDN then serves as HTML. Upload URLs use a separate client whose signer covers both headers, so S3 rejects a mismatched request with a 403. Other presigned URLs aren't affected. If a caller doesn't pass a type, the type for the path's extension is signed.renameFile(). That copies the object's metadata, so the type and visibility set on the upload are what the CDN serves.src/fs/TemporaryUploadUrlInterface.phpshims the interface for Craft versions before 5.13, the same wayReleasableQueueInterfacedoes.This has no effect until the Craft side ships. Cloud's own control panel uploader (
cloud/assets/*andUploader.js) stays in place for older Craft versions, and will be removed once Cloud requires a Craft version that includes upload sessions.Related issues
craft\base\TemporaryUploadUrlInterface. It replaced Send MCP uploads directly to storage that accepts them cms#20630, which is closed.Tempcontainer mapping, so Cloud's isTmpFs.