没网的时候控制台有okhttp的回调
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
2024-04-26 19:46:35.089 15477-16397 System.err com.example.rprint W at okhttp3.RealCall.execute(RealCall.kt:66)
at com.alibaba.sdk.android.oss.network.OSSRequestTask.call
suspend fun syncUploadFile( objectName: String, dir: String, uploadFilePath: String? ): String = withContext(customDispatcher) { try { // 构造上传请求 val put = PutObjectRequest(bucket, dir + objectName, uploadFilePath) // 异步上传时可以设置进度回调 put.progressCallback = OSSProgressCallback { request, currentSize, totalSize -> Log.d( TAG, "PutObject>> currentSize: $currentSize totalSize: $totalSize" ) } // 使用协程异步等待上传结果 val result = CompletableDeferred()
val task = oss.asyncPutObject(
put,
object : OSSCompletedCallback<PutObjectRequest?, PutObjectResult?> {
override fun onSuccess(
request: PutObjectRequest?, aliresult: PutObjectResult?
) {
val url = oss.presignPublicObjectURL(bucket, dir + objectName);
Log.d(TAG, "PutObject>> UploadSuccess>>>>${url}")
result.complete(url) // 完成Deferred,返回url
}
没网的时候控制台有okhttp的回调 at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184) 2024-04-26 19:46:35.089 15477-16397 System.err com.example.rprint W at okhttp3.RealCall.execute(RealCall.kt:66) at com.alibaba.sdk.android.oss.network.OSSRequestTask.call