我有以下网址
URL TO CALL
在界面中,我有
@GET("storage/presigned-url?bucketName=files&key=payment-receipt/{fileName}&httpVerb=2&contentType=image/jpeg") suspend fun fileUploadPathCheque(@Path("fileName") name: String): Response<String>
我想用一些值替换文件名
我将函数调用为
Api.fileUploadPathCheque(UUID.randomUUID().toString().plus(".jpg"))
我得到以下例外
ava.lang.IllegalArgumentException: URL query string "bucketName=files&key=payment-receipt/{fileName}&httpVerb=2&contentType=image/jpeg" must not have replace block. For dynamic query parameters use @Query.
做这件事的正确方法是什么?
异常是不言自明的,您需要为 key .差不多
key
@GET("storage/presigned-url?bucketName=files&httpVerb=2&contentType=image/jpeg") suspend fun fileUploadPathCheque(@Query("key") name: String): Response<String>`
然后称之为追加 payment-receipt/ 要传递参数,请执行以下操作:
payment-receipt/
Api.fileUploadPathCheque("payment-receipt/" + UUID.randomUUID().toString().plus(".jpg"))
这应该对你有用。