-
Notifications
You must be signed in to change notification settings - Fork 1
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
Data and file upload support #43
Conversation
@cejanen What I mean was just different approaches to the same thing which is absolutely fine, but most of the functionality is the same so I was thinking whether it would be feasible to have one generic solution for both that could be inherited from or something in that sense.
|
Some things (objects) could certainly be unified, but I'd rather not decide this as it changes the implementation of either of the managers. |
got an error when uploading a specific photo from the simulator
|
I also got this, but it's the simulator problem with corrupted images, nothing to do with uploading I think |
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.
@tonyskansf I answered last comments or resolved issues, we're almost done 👍
…und upload, error handling
[FIX] Upload manager adjustments
Add `multipart/form-data` support
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.
🥡
This pull request introduces an upload feature allowing clients to upload data and files (no stream or multipart file support yet). The implementation follows the existing download feature design with slight deviation whilst aiming to keep consistency and familiarity with the API. With that, the changes also include an example that showcases the usage of the API.
Please, do not consider this implementation as final but rather as the first draft.
Video
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-06-13.at.17.24.34.mp4
Implementation
UploadTask
The central component is the
UploadTask
object that encapsulates the ongoingURLSessionUploadTask
and provides the task's state updates. Each upload request creates an upload task instance that is internally stored until the request is completed. In case of a failed request, the UploadTask serves as the representation of the failed request and is important in subsequent retry attempts.UploadTask.State
This object represents the progress of the upload request and is updated continuously by the internal publisher. It is then available to the client as an asynchronous sequence. Since the implementation creates the
URLSessionUploadTask
with completion handlers, the response is accessible only upon the task's completion. Consequently, the response or error is delivered within the upload task's state.Retryable
The
UploadTask
conforms to theRetryable
protocol instead of theUploadAPIManager
as is in theDownloadAPIManager
. This emphasizes the intention that the task itself is retryable, rather than the manager. Despite potentially deviating from the original design of the protocol, this approach seems to work as well. Each upload task has itsretryCounter: Counter
that determines whether the task should be retried based on theRetryConfiguration
.Additional Notes