分段上传请求中的进度对话框

时间:2018-10-04 05:34:50

标签: android kotlin

我正在使用Multipart方法将pdf文件从Android上传到服务器。

fun uploadMultipart() {

        val apiUrl = getString(R.string.service_api)+"addDoc"
            try {
                val uploadId = UUID.randomUUID().toString()
                MultipartUploadRequest(this@AddDocSecondActivity, uploadId, apiUrl)
                        .addFileToUpload(PdfPathHolder, "resource_center_pdf")
                        .addParameter("title", titles.text.toString().trim())
                        .addParameter("tags",  tag.text.toString().trim())
                        .addParameter("categoryid", categoty_id)
                        .addParameter("country_id", country_id)
                        .addParameter("description", txtDiscription.text.toString().trim())
                        .addParameter("member_id", preferenceHelper?.getMyData(Utilities.USERID)!!)
                        .setNotificationConfig(UploadNotificationConfig())
                        .setMaxRetries(2)
                        .startUpload()

            } catch (exc :Exception) {
             Toast.makeText(this, "Error While uploading...", Toast.LENGTH_SHORT).show();
           }
}

如何显示进度对话框,以便用户知道已上传了多少文件?

0 个答案:

没有答案