Created
November 11, 2018 00:50
-
-
Save dokinkon/e998c1238bd657dcb7aa297e3c2095f2 to your computer and use it in GitHub Desktop.
Retrofit如何避免multipart-form-data中的參數被雙引號夾起來
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <reified T> createWebService(okHttpClient: OkHttpClient, url: String): T { | |
val retrofit = Retrofit.Builder() | |
.baseUrl(url) | |
.client(okHttpClient) | |
.addConverterFactory(ScalarsConverterFactory.create()) // <--- 避免產生雙引號在multipart-formdata的參數中 | |
.addConverterFactory(GsonConverterFactory.create()) // <-- ScalarsConverterFactory要放在GsonConverterFactory之前 | |
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build() | |
return retrofit.create(T::class.java) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment