下面的代码给出了错误:使用'of(Map):Headers'是一个错误。功能移至扩展名。
val mapH = mapOf (Pair("Content-Disposition",
"file; filename=\"$encodedFileName\""),
Pair("Content-Transfer-Encoding",
"binary"))
val headers = Headers.of (mapH)
阅读了https://square.github.io/okhttp/upgrading_to_okhttp_4/#extension-functions的文档后,我尝试了:
val headers = headersOf(mapH)
and also
val headers = mapH.toHeaders()
并得到以下错误:未解析的引用:headersOf和toHeaders。为什么呢
最佳答案
试试这个:
import okhttp3.Headers.Companion.toHeaders
关于kotlin - Kotlin OkHttp3使用 'of(Map<String, String>): Headers'是错误。功能移至扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60283974/