Skip to content

Commit

Permalink
Add creation and modification date to response (#530)
Browse files Browse the repository at this point in the history
* added creationDate and modificationDate to response object

added modificationDate to Android response

* Update Compression.m (#529)

Addition of passthrough preset option

Update README to include dates in response
  • Loading branch information
jasongaare authored and ivpusic committed Dec 5, 2017
1 parent a4a2247 commit b59db6b
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 83 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -129,6 +129,8 @@ ImagePicker.clean().then(() => {
| size | number | Selected image size in bytes |
| data | base64 | Optional base64 selected file representation |
| exif | object | Extracted exif data from image. Response format is platform specific |
| creationDate (ios only) | string | UNIX timestamp when image was created |
| modificationDate | string | UNIX timestamp when image was last modified |

# Install

Expand Down
Expand Up @@ -463,13 +463,15 @@ public void invoke(Object... args) {

try {
Bitmap bmp = validateVideo(videoPath);
long modificationDate = new File(videoPath).lastModified();

WritableMap video = new WritableNativeMap();
video.putInt("width", bmp.getWidth());
video.putInt("height", bmp.getHeight());
video.putString("mime", mime);
video.putInt("size", (int) new File(videoPath).length());
video.putString("path", "file://" + videoPath);
video.putString("modificationDate", String.valueOf(modificationDate));

resultCollector.notifySuccess(video);
} catch (Exception e) {
Expand Down Expand Up @@ -532,12 +534,14 @@ private WritableMap getImage(final Activity activity, String path) throws Except
File compressedImage = compression.compressImage(activity, options, path);
String compressedImagePath = compressedImage.getPath();
BitmapFactory.Options options = validateImage(compressedImagePath);
long modificationDate = new File(path).lastModified();

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));

if (includeBase64) {
image.putString("data", getBase64StringFromFile(compressedImagePath));
Expand Down Expand Up @@ -581,7 +585,7 @@ private void startCropping(Activity activity, Uri uri) {
options.setShowCropGrid(showCropGuidelines);
options.setHideBottomControls(hideBottomControls);
if (cropperToolbarTitle != null) {
options.setToolbarTitle(cropperToolbarTitle);
options.setToolbarTitle(cropperToolbarTitle);
}
if (enableRotationGesture) {
// UCropActivity.ALL = enable both rotation & scaling
Expand Down

0 comments on commit b59db6b

Please sign in to comment.