Skip to content

Commit

Permalink
Fix DNG/RAW Upload Error (#5543)
Browse files Browse the repository at this point in the history
* Fix DNG/RAW Upload Error

* Fix DNG/RAW Upload Error

* supported formats added

* cleanup
  • Loading branch information
shashankiitbhu authored Feb 14, 2024
1 parent 1cbce77 commit 2d5b7cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -130,4 +138,4 @@ class ImageFileLoader(val context: Context) : CoroutineScope{
* Sha1 for image (original image).
*
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ private static Intent createGalleryIntent(@NonNull Context context, int type,
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);
}

/**
Expand Down Expand Up @@ -401,4 +404,4 @@ public interface Callbacks {

void onCanceled(FilePicker.ImageSource source, int type);
}
}
}

0 comments on commit 2d5b7cc

Please sign in to comment.