The inspiration for this issue is this comment https://github.com/Moya/Moya/issues/1565#issuecomment-383371379 by @ffittschen
He's using .uploadFile(URL) to upload Data by first writing that Data to a URL.
It seems reasonable to add a .uploadData(Data) case to the Task enum.
My main concern is the scalability of the enum as we continue to add more cases. I think this is one of the drawbacks of flattening it and not using the previous strategy of composing associated values.
Yeah, now the usage of multiple enums seems more fitting, but I would try to leave it as it is until we face another bigger improvement that we need to do in Task implementation.
Not having this in Moya is kind of haunting me today. I don't want to write my data to a temporary file just to get upload progress (as described in the comment above) -- because doing so is wasteful and I also have to worry about cleaning up my URL.
Is there any reason you are thinking of an addition instead of a replacement? To me having .uploadFile(URL) and .uploadData(Data) is not necessary as their use case would be very close.
.uploadData(Data) seems to be more handy, and it is very easy to get Data from a file.
@amaurydavid At this point I would be open to review a PR that adds the uploadData(Data) option to the Task. There isn't much more cases we would want to explore, and we might possibly reduce the number of cases once default parameters for enum cases are finally there.
Most helpful comment
Not having this in Moya is kind of haunting me today. I don't want to write my data to a temporary file just to get upload progress (as described in the comment above) -- because doing so is wasteful and I also have to worry about cleaning up my URL.