Skip to content
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

Background upload / download using URLSession transport #54

Open
hivenet-erwanjestin opened this issue Sep 13, 2023 · 4 comments
Open

Comments

@hivenet-erwanjestin
Copy link

We are heavily using openapi to generate our REST library.
In this library we do files upload and download.

Everything works pretty well but now we want to allow background requests.
That means we need to use an URLSession with URLSessionConfiguration.background().

I saw we could override the URLSession but the most challenging part is we need a dedicate delegate for each API we have running in the background.

What's the best way to manage that with an openapi generated library?
For now, we are considering doing it manually, so removing this library from our code :'(

@czechboy0
Copy link
Collaborator

Hi @hivenet-erwanjestin,

I think it should be possible to make this work with the generated client. I can't offer much support on using background tasks with URLSession, but how you can proceed:

After you have it working, you could contribute your changes back to https://github.com/apple/swift-openapi-urlsession so that it also works for others using background tasks.

But you should be able to use the generator in this repo, and the runtime library without any modifications, all the changes should be isolated to the URLSession transport.

@czechboy0 czechboy0 changed the title Background upload / download Background upload / download using URLSession transport Sep 13, 2023
@czechboy0 czechboy0 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2023
@mooshee
Copy link

mooshee commented Aug 27, 2024

+1 would be nice to have background support

@czechboy0 czechboy0 transferred this issue from apple/swift-openapi-generator Sep 16, 2024
@czechboy0 czechboy0 reopened this Sep 16, 2024
@guoye-zhang
Copy link
Contributor

This is somewhat tricky since background sessions work with files instead of data streams. The code needs to be changed to upload a file or download a file, and per-task delegate is not available with background sessions.

@czechboy0
Copy link
Collaborator

Good points. Yeah I imagine that if background tasks are to be supported here, we need a proposed design of how it'd all work. Let's just use this issue to track any progress on that, ideally driven by someone who has a use case here.

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

No branches or pull requests

4 participants