Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added creationDate for Android #2034

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;



Expand Down Expand Up @@ -684,14 +686,18 @@ 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);
image.putInt("height", options.outHeight);
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));
Expand Down