From b07203e68aff303817d3003119c5ce3d9774f905 Mon Sep 17 00:00:00 2001 From: changwoolab Date: Mon, 18 Mar 2024 18:40:32 +0900 Subject: [PATCH 1/2] feat: add creationDate --- README.md | 2 +- .../com/reactnative/ivpusic/imagepicker/PickerModule.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 651e1104e..ac4ede1f5 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ NOTE: Some of these types may not be available on all iOS versions. Be sure to c | data | base64 | Optional base64 selected file representation | | exif | object | Extracted exif data from image. Response format is platform specific | | cropRect | object | Cropped image rectangle (width, height, x, y) | -| creationDate (ios only) | string | UNIX timestamp when image was created | +| creationDate | string | UNIX timestamp when image was created | | modificationDate | string | UNIX timestamp when image was last modified | # Install diff --git a/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java b/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java index 5de0845b2..3f70dffd0 100644 --- a/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java +++ b/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java @@ -684,7 +684,10 @@ private WritableMap getImage(final Activity activity, String path) throws Except File compressedImage = compression.compressImage(this.reactContext, options, path, original); String compressedImagePath = compressedImage.getPath(); BitmapFactory.Options options = validateImage(compressedImagePath); - long modificationDate = new File(path).lastModified(); + File file = new File(path); + long modificationDate = file.lastModified(); + BasicFileAttributes attr = Files.readAttributes(file.toPath(), BasicFileAttributes.class); + long createdAt = attr.creationTime().toMillis(); image.putString("path", "file://" + compressedImagePath); image.putInt("width", options.outWidth); @@ -692,6 +695,7 @@ private WritableMap getImage(final Activity activity, String path) throws Except image.putString("mime", options.outMimeType); image.putInt("size", (int) new File(compressedImagePath).length()); image.putString("modificationDate", String.valueOf(modificationDate)); + image.putString("creationDate", String.valueOf(createdAt)); if (includeBase64) { image.putString("data", getBase64StringFromFile(compressedImagePath)); From 390e73eca7c02ecdf4daca630ac67320ed585bfc Mon Sep 17 00:00:00 2001 From: changwoolab Date: Mon, 18 Mar 2024 18:46:58 +0900 Subject: [PATCH 2/2] fix: import --- .../java/com/reactnative/ivpusic/imagepicker/PickerModule.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java b/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java index 3f70dffd0..b36b71e4f 100644 --- a/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java +++ b/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java @@ -51,6 +51,8 @@ import java.util.List; import java.util.UUID; import java.util.concurrent.Callable; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.Files;