Android 改型2的作用域存储视频上载问题(java.io.FileNotFoundException:打开失败:eNot(无此类文件或目录)
我想上传视频使用改型在API级别Q和更高Android 改型2的作用域存储视频上载问题(java.io.FileNotFoundException:打开失败:eNot(无此类文件或目录),android,kotlin,android-10.0,Android,Kotlin,Android 10.0,我想上传视频使用改型在API级别Q和更高 我创建了一个媒体助手,它给我一个图像和视频文件列表 return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { val collectionWithPending = MediaStore.setIncludePending(collection) CursorLoader(context, collectionWithPending, projection, selec
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val collectionWithPending = MediaStore.setIncludePending(collection)
CursorLoader(context, collectionWithPending, projection, selection, null, sortOrder)
} else {
CursorLoader(context, collection, projection, selection, null, sortOrder)
}
image.context.contentResolver.openFileDescriptor(mData.contentUri!!, FILE_OPEN_READ_MODE).use {
image.setPicture(mData.contentUri, RequestOptions().placeholder(R.color.white).error(R.color.white).diskCacheStrategy(DiskCacheStrategy.NONE))
}
inline fun <reified T : Any>getRetrofit(): T {
val retrofit = Retrofit.Builder()
.client(getDefaultClient())
.baseUrl(BASE_URL)
.addConverterFactory(getCustomConverterFactory())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()
return retrofit.create(T::class.java)}
//Api call Interface
interface UploadImagesRetrofitService {
@Multipart
@POST(MEDIA)
fun getUploadMedia(
@Header(ID) xID: String? = null,
@Header(MEDIA_TYPE) mediaType: String? = null,
@Header(UPLOAD_TYPE) uploadType: String? = null,
@Part files: MultipartBody.Part
): Observable<UploadMediaResponse>
}
//Access the Interface
fun getMediaUpload(xID: String, mediaType: String, uploadType: String, files: MultipartBody.Part): Observable<UploadMediaResponse> {
return getRetrofitServiceTTU<UploadImagesRetrofitService>().getUploadMedia(xID, mediaType, uploadType, files)
}
fun getUpload(xID: String, mediaType: String, uploadType: String, files: MultipartBody.Part, height: Int = 0, width: Int = 0) {
addDisposable(repo.getMediaUpload(xID, mediaType, uploadType, files).subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe({
if (it != null && it.reponseCode == 0) {
it.height = height
it.width = width
it.mediaType = mMediaType
mUploadingInterFace.getSuccessResponse(it)
} else {
mUploadingInterFace.getErrorResponse(it.responseError)
}
}, { thr ->
thr.printStackTrace()
if ((mContext?.isValid() == true) && mContext is BaseActivity) mContext.showError(mContext.getString(R.string.error_upload_media))
}))
}