-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add callback function in storefile()
to show download progress?
#54
Comments
Can you give me an example of How to use response stream? # example asynchronous API that streams matching Pet instances into response_stream
findPetsByStatus(
api::PetApi,
response_stream::Channel,
status::Vector{String}) -> (response_stream, http_response) |
I know... response object will simply chan = Channel(2)
findPetsByStatus(api,chan;statu)
take!(chan) |
I figured it out, So if we want actual download progression, we need to add file download code in do_request(), use Downloads.download. And for files downloads in OpenAPI definition:
The return type will be |
Yes, we need to invoke the underlying It is not clear yet how this should be structured. I can think of two ways:
I am leaning towards the second option ATM. |
I don't think providing IO is a good idea, this requires modifying the parameters list of many existing functions. Maybe you want? function download(api_call::Function;
folder::AbstractString = pwd(),
filename::Union{String,Nothing} = nothing,
)::Tuple{Any,ApiResponse,String}
# init io
api_call(api,queries...;io)
# rename file, move to target folder
end First, codegen needs to add the IO parameter for ALL API call function: function datasets_download(_api::Api, queries...; io)
_ctx = _oacinternal_datasets_download(_api, queries...)
return OpenAPI.Clients.exec(_ctx; io)
end And function exec(ctx::Ctx, stream_to::Union{Channel,Nothing}=nothing; io)
stream = stream_to !== nothing
resp, output = do_request(ctx, stream; stream_to=stream_to, io)
...
end function do_request(ctx::Ctx, stream::Bool=false; stream_to::Union{Channel,Nothing}=nothing, io)
...
# io exist
Downloads.download(url;output=io)
...
end |
Maybe this is a good solution. But no need to generate a different endpoint? First, detecting this request is a file download (from Then, change Last, add the download code in The exposed API like: filepath,http_response = datasets_download(api,queries...) In this way, there is no need to modify Codegen and many other function parameters list. If users want to save the response result to a file. that's what |
And one more question: How to add |
|
I mean, the order in which the functions are called is: Add progress callback function for It is a little trivial and needs to modify many existing function argument lists. I don't know if there is a better solution. |
It seems impossible because
api_call()
have received all bytes in RAM here.I don't know if I'm thinking right. Is it possible to add a progress callback function?
The text was updated successfully, but these errors were encountered: