Skip to content

Swift Create Media Support #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Draft

Swift Create Media Support #412

wants to merge 5 commits into from

Conversation

jkmassel
Copy link
Contributor

No description provided.

@jkmassel jkmassel changed the title Jkmassel/create media Swift Create Media Support Nov 27, 2024
@jkmassel jkmassel force-pushed the jkmassel/create-media branch 2 times, most recently from 0e955f9 to 1e0eb05 Compare November 27, 2024 22:39
@jkmassel jkmassel mentioned this pull request Dec 2, 2024
Base automatically changed from create-media-2 to trunk December 2, 2024 22:43
@jkmassel jkmassel force-pushed the jkmassel/create-media branch from 1e0eb05 to 74d5023 Compare May 5, 2025 22:19
}
public func uploadMedia(mediaUploadRequest: MediaUploadRequest) async throws -> WpNetworkResponse {
let urlrequest = try await mediaUploadRequest.asUrlRequest()
let (_, response) = try await self.fetch(request: self.preflight(urlrequest))
Copy link
Contributor

Choose a reason for hiding this comment

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

URLSession.uploadTask is probably more appropriate for uploading media. We can choose to stream from a file or memory. Things may go wrong when users choose to upload a video if we always read the file content into memory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're not currently reading the file into memory – instead, we make a file that contains the entire request body then provide that as an InputStream on the URLRequest.

It might make sense to separate binary upload from the file metadata though, in which case we could definitely use an upload task

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.

3 participants