SHARE
TWEET

Untitled

a guest Feb 16th, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //ini api nya
  2.     @Multipart
  3.     @POST(ApiRequest.SEND_PDO)
  4.     fun sendPDOO(
  5.         @Header("Authorization") header: RequestBody,
  6.         @Part ("pod") pod: MultipartBody.Part,
  7.         @Part("receiver") receiver: RequestBody,
  8.         @Part("qty_received") qty_received: RequestBody,
  9.         @Part("notes") notes: RequestBody
  10.         ): Call<Default>
  11.  
  12.  
  13. //ini di fragment upload foto nya
  14. private fun sendtoserver(
  15.         received: String,
  16.         toStringuantity: String,
  17.         notes: String,
  18.         credentialHeader: String
  19.     ) {
  20.         val requestHeader = RequestBody.create("multipart".toMediaTypeOrNull(), credentialHeader)
  21.         val requestBody = RequestBody.create("multipart".toMediaTypeOrNull(), compressor)
  22.         val reqreceived = RequestBody.create("multipart".toMediaTypeOrNull(), received)
  23.         val reqtoStringuantity = RequestBody.create("multipart".toMediaTypeOrNull(), toStringuantity)
  24.         val reqnotes = RequestBody.create("multipart".toMediaTypeOrNull(), notes)
  25.         pod = MultipartBody.Part.createFormData("imagename",compressor.absolutePath,requestBody)
  26.  
  27.         val call: Call<Default> = apiClient.getClient.sendPDOO(requestHeader,pod, reqreceived,reqtoStringuantity, reqnotes)
  28.         call.enqueue(object : retrofit2.Callback<Default>{
  29.             override fun onResponse(
  30.                 call: Call<Default>,
  31.                 response: Response<Default>
  32.             ) {
  33.             }
  34.             override fun onFailure(call: Call<Default>, t: Throwable) {
  35.                 toast(context, "Gagal")
  36.             }
  37.         })
  38.  
  39.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top