-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: trunk
Are you sure you want to change the base?
Conversation
0e955f9
to
1e0eb05
Compare
1e0eb05
to
74d5023
Compare
} | ||
public func uploadMedia(mediaUploadRequest: MediaUploadRequest) async throws -> WpNetworkResponse { | ||
let urlrequest = try await mediaUploadRequest.asUrlRequest() | ||
let (_, response) = try await self.fetch(request: self.preflight(urlrequest)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
No description provided.