问题
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