Skip to content

feat: allow commands to receive File objects#15978

Merged
Rich-Harris merged 7 commits into
mainfrom
command-file
Jun 8, 2026
Merged

feat: allow commands to receive File objects#15978
Rich-Harris merged 7 commits into
mainfrom
command-file

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

While it's generally better to use a <form> to deal with files, sometimes it imposes unreasonable constraints on a design. In these cases it would be nice to be able to pass File objects to a command.

A short while ago, devalue added a stringifyAsync method that makes this possible — we just need a custom reducer that returns a Promise. We could potentially use the same trick for other things in future, or even allow async custom transports, but for now this is deliberately narrowly scoped.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot

changeset-bot Bot commented Jun 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8e27b76

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Minor

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

@svelte-docs-bot

Copy link
Copy Markdown

Comment thread packages/kit/src/runtime/shared.js Outdated
Comment on lines +329 to +330
const bytes = text_encoder.encode(json_string);
return base64_encode(bytes).replaceAll('=', '').replaceAll('+', '-').replaceAll('/', '_');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little nit: we could deduplicate this here and in stringify_remote_arg. Maybe a url_friendly_base64_encode 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, agree with Tee

@Rich-Harris Rich-Harris merged commit c630529 into main Jun 8, 2026
29 checks passed
@Rich-Harris Rich-Harris deleted the command-file branch June 8, 2026 19:02
@github-actions github-actions Bot mentioned this pull request Jun 8, 2026
@phi-bre phi-bre mentioned this pull request Jun 8, 2026
6 tasks
Rich-Harris pushed a commit that referenced this pull request Jun 8, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @sveltejs/kit@2.64.0

### Minor Changes


- feat: allow commands to receive `File` objects
([#15978](#15978))


### Patch Changes


- fix: avoid server components from being bundled if SSR is turned off
for a route ([#15982](#15982))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@hyunbinseo

hyunbinseo commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Does this close this issue?:

@teemingc teemingc linked an issue Jun 9, 2026 that may be closed by this pull request
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.

Cannot upload File using command remote function

4 participants