MultipartUploadRequest (Error during upload) android 10

眉间皱痕 提交于 2020-12-15 05:19:22

问题


I have used this in multiple projects never got any error but when i tried this in android 10 its attempt to upload but after some time it gives error during upload. If there is any one who

tried this way as well: <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

`My code:

 try{
  String uploadId = UUID.randomUUID().toString();

        Toast.makeText(this, path, Toast.LENGTH_SHORT).show();
        //Creating a multi part request


        new MultipartUploadRequest(this, Constants.UPLOAD_URL)
                .setMethod("POST")
                .addFileToUpload(path, "image") //Adding file
                .addHeader("x-amz-acl", "bucket-owner-full-control")
                .addParameter("UserID", userId) //Adding text parameter to the request
                .setAutoDeleteFilesAfterSuccessfulUpload(false)
                .setUsesFixedLengthStreamingMode(true)
                .setNotificationConfig(new UploadNotificationConfig())
                .setMaxRetries(5)
                .startUpload(); //Starting the upload

    } catch (Exception exc) {
        Toast.makeText(this, exc.getMessage(), Toast.LENGTH_SHORT).show();
    }`

Console Error: I/System.out: [okhttp]:check permission begin! W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out: [okhttp] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils I/System.out: [socket]:check permission begin! W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out: [socket] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils I/System.out: [okhttp]:check permission begin! W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out: [okhttp] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils I/System.out: [socket]:check permission begin! W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out: [socket] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils I/System.out: [okhttp]:check permission begin! W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out: [okhttp] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils I/System.out: [socket]:check permission begin! W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar I/System.out: [socket] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils


回答1:


I got the answer after lot of research it was my own mistake if it can save someone's day use this in your Manifest:

'android:requestLegacyExternalStorage="true"'



来源:https://stackoverflow.com/questions/63462169/multipartuploadrequest-error-during-upload-android-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!