Skip to content

feat!: remove MediaUploadDelegate.uploadFile - #629

Draft
jkmassel wants to merge 1 commit into
feat/media-uploader-protocolfrom
feat/remove-upload-file-hook
Draft

feat!: remove MediaUploadDelegate.uploadFile#629
jkmassel wants to merge 1 commit into
feat/media-uploader-protocolfrom
feat/remove-upload-file-hook

Conversation

@jkmassel

@jkmassel jkmassel commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Stacked on #628. Sixth of ten PRs splitting #621. Almost entirely deletions.

What?

Removes uploadFile from MediaUploadDelegate on both platforms. MediaUploader (#628) replaces it.

Why?

Returning a raw response split one upload's HTTP across two owners — the host performed the POST, the editor drove the post-process retries and orphan cleanup behind it — and the hook received no form fields, so an attachment it uploaded landed unattached to its post. Neither is fixable while the hook returns a raw response.

What is left is a clean division: a delegate transforms bytes and GutenbergKit owns delivery and its retries; a MediaUploader owns delivery and its retries entirely. There is no longer an in-between where the host performs the upload but the editor retries it.

How?

  • The protocol requirement, its default implementation, and the delivery branch that called it, on both platforms.
  • handlesFile no longer gates the temp copy for two callers, only for processFile — and only when no uploader is set.
  • MediaUploadResponse drops to internal on both platforms: uploadFile was the only public API that named it.
  • The deprecation warning feat: add MediaUploader, for a host that owns the whole upload #628 left in GutenbergKit's own build goes away with the hook.

Testing Instructions

Tests for the removed path are rewritten rather than deleted — the delegate now processes and the internal client delivers, which is what the remaining path does.

  • swift test — host suite green
  • Android :Gutenberg:testDebugUnitTest green
  • iOS Simulator xcodebuild; Android demo compiles
  • SwiftLint + Detekt clean

Breaking change

Hosts implementing uploadFile must conform to MediaUploader instead. Hosts that only implement processFile / handlesFile are unaffected. Migration needed in WordPress-iOS, WordPress-Android and Jetpack.

`MediaUploader` replaces it. Returning a raw response split one upload's
HTTP across two owners — the host performed the `POST`, the editor drove
the `post-process` retries and orphan cleanup behind it — and the hook
received no form fields, so an attachment it uploaded landed unattached to
its post. Neither is fixable while the hook returns a raw response, which
is what the replacement changes.

What is left is a clean division: a delegate transforms bytes and
GutenbergKit owns delivery and its retries; a `MediaUploader` owns
delivery and its retries entirely. There is no longer an in-between where
the host performs the upload but the editor retries it.

`handlesFile` no longer gates the temp copy for two callers, only for
`processFile` — and only when no uploader is set, since an uploader takes
over delivery for every file.

`MediaUploadResponse` drops to internal on both platforms: `uploadFile`
was the only public API that named it.

BREAKING CHANGE: hosts implementing `uploadFile` must conform to
`MediaUploader` instead. Hosts that only implement `processFile` /
`handlesFile` are unaffected.
@jkmassel jkmassel added [Type] Breaking Change For PRs that introduce a change that will break existing functionality Android iOS labels Sep 5, 2026
@jkmassel jkmassel self-assigned this Sep 5, 2026
@wpmobilebot

Copy link
Copy Markdown

XCFramework Build

This PR's XCFramework is available for testing. Add the following to your Package.swift:

.package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/629")

Built from f5cbf24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android iOS [Type] Breaking Change For PRs that introduce a change that will break existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants