@@ -1023,24 +1023,32 @@ class ImageApi(dockerClientConfig: DockerClientConfig = defaultClientConfig, pro
10231023 * @throws ServerException If the API returns a server error response
10241024 */
10251025 @Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
1026- fun imageLoad (quiet : Boolean? , imagesTarball : java.io.File ? ) {
1026+ @JvmOverloads
1027+ fun imageLoad (
1028+ quiet : Boolean? , imagesTarball : java.io.File ? ,
1029+ callback : StreamCallback <CreateImageInfo ?>? = null, timeoutMillis : Long? = null /* = 24.hours.toLongMilliseconds()*/
1030+ ) {
10271031 val localVariableConfig = imageLoadRequestConfig(quiet = quiet, imagesTarball = imagesTarball)
10281032
1029- val localVarResponse = requestStream<Any ?>(
1033+ val localVarResponse = requestStream<CreateImageInfo ?>(
10301034 localVariableConfig
10311035 )
10321036
1033- val timeout = Duration .of(1 , ChronoUnit .MINUTES )
1034- val callback = LoggingCallback <Any >()
1037+ val timeout = if (timeoutMillis == null ) {
1038+ Duration .of(10 , ChronoUnit .MINUTES )
1039+ } else {
1040+ Duration .of(timeoutMillis, ChronoUnit .MILLIS )
1041+ }
1042+ val actualCallback = callback ? : LoggingCallback <CreateImageInfo ?>()
10351043
10361044 return when (localVarResponse.responseType) {
10371045 ResponseType .Success -> {
10381046 runBlocking {
10391047 launch {
10401048 withTimeout(timeout.toMillis()) {
1041- callback .onStarting(this @launch::cancel)
1042- (localVarResponse as SuccessStream <* >).data.collect { callback .onNext(it) }
1043- callback .onFinished()
1049+ actualCallback .onStarting(this @launch::cancel)
1050+ (( localVarResponse as SuccessStream <* >).data as Flow < CreateImageInfo >) .collect { actualCallback .onNext(it) }
1051+ actualCallback .onFinished()
10441052 }
10451053 }
10461054 }
0 commit comments