Fix DNG/RAW Upload Error (#5543)

* Fix DNG/RAW Upload Error

* Fix DNG/RAW Upload Error

* supported formats added

* cleanup
This commit is contained in:
Shashank Kumar 2024-02-14 17:39:48 +05:30 committed by GitHub
parent 1cbce77d5f
commit 2d5b7cc579
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View file

@ -11,7 +11,9 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import java.util.*
import java.util.Calendar
import java.util.Date
import java.util.Locale
import kotlin.coroutines.CoroutineContext
/**
@ -90,6 +92,12 @@ class ImageFileLoader(val context: Context) : CoroutineScope{
}
if (file != null && file.exists() && name != null && path != null && bucketName != null) {
val extension = path.substringAfterLast(".", "")
// Check if the extension is one of the allowed types
if (extension.lowercase(Locale.ROOT) !in arrayOf("jpg", "jpeg", "png", "svg", "gif", "tiff", "webp", "xcf")) {
continue
}
val uri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id)
val calendar = Calendar.getInstance()
@ -130,4 +138,4 @@ class ImageFileLoader(val context: Context) : CoroutineScope{
* Sha1 for image (original image).
*
*/
}
}

View file

@ -48,8 +48,11 @@ public class FilePicker implements Constants {
boolean openDocumentIntentPreferred) {
// storing picked image type to shared preferences
storeType(context, type);
//Supported types are SVG, PNG and JPEG,GIF, TIFF, WebP, XCF
final String[] mimeTypes = { "image/jpg","image/png","image/jpeg", "image/gif", "image/tiff", "image/webp", "image/xcf", "image/svg+xml", "image/webp"};
return plainGalleryPickerIntent(openDocumentIntentPreferred)
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, configuration(context).allowsMultiplePickingInGallery());
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, configuration(context).allowsMultiplePickingInGallery())
.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
}
/**
@ -401,4 +404,4 @@ public class FilePicker implements Constants {
void onCanceled(FilePicker.ImageSource source, int type);
}
}
}