From c5d2a34ebd447d98b556b8432ef114301b9e5f1c Mon Sep 17 00:00:00 2001 From: onurays Date: Fri, 26 Jun 2020 12:58:41 +0300 Subject: [PATCH] Documentation added to explain creating a cache file. --- .../android/internal/session/content/UploadContentWorker.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt index 1ce805bb66..c5a91cbd9e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/UploadContentWorker.kt @@ -161,6 +161,10 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter var uploadedFileEncryptedFileInfo: EncryptedFileInfo? = null return try { + // Compressor library works with File instead of Uri for now. Since Scoped Storage doesn't allow us to access files directly, we should copy + // it to a cache folder by using InputStream and OutputStream. + // https://github.com/zetbaitsu/Compressor/pull/150 + // As soon as the above PR is merged, we can use attachment.queryUri instead of creating a cacheFile. var cacheFile = File.createTempFile(attachment.name ?: UUID.randomUUID().toString(), ".jpg", context.cacheDir) cacheFile.parentFile?.mkdirs() if (cacheFile.exists()) {