Repository navigation
Issue direct upload URLs from Cloud filesystems - #216
Open
brandonkelly wants to merge 1 commit into
Open
brandonkelly wants to merge 1 commit into
brandonkelly wants to merge 1 commit into
Conversation
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>
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
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.
Summary
Craft's MCP server can now upload files straight to S3 on Cloud, the way the control panel uploader does. Today they go through Craft's
mcp/uploadaction, which is capped by Lambda's 6 MB request limit.Fsimplements Craft's newcraft\base\DirectUploadFsInterface(5.12.2+). It returns null underuseLocalFs, so Craft falls back to its own PUT endpoint.src/fs/DirectUploadFsInterface.phpshims the interface for older Craft versions, the same wayReleasableQueueInterfacedoes.presignedUrl()andgetDirectUploadUrl()now share one presign helper, so the returned headers come from the same signed request as the URL.S3 can't enforce a size limit on a presigned PUT. Craft checks
maxUploadFileSizewhen the upload is claimed.Evidence
tests/unit/FsTest.php: TmpFs URL key<env>/storage/tmp/mcp-uploads/abc, headers equal the signed headers (x-amz-meta-visibility: private, plusx-amz-meta-max-ageon AssetsFs), null underuseLocalFs. Full suite: 103 tests pass; ECS and PHPStan clean.PUT→403 SignatureDoesNotMatchContent-Type): a 7 MBPUT→200;fileExists,getFileSizeandreadreturn the bytes; object metadata{"visibility":"private"}craft\base\DirectUploadFsInterfacedefined,TmpFsimplements it (the 5.12.2+ branch of the shim).Related issues
craft\base\DirectUploadFsInterfaceand uses it inassets_upload_url.Tempcontainer mapping, so Cloud's isTmpFs.Both Craft PRs need to ship before this has any effect on Cloud.