Skip to content

Commit

Permalink
Improvement: Copdy instead of overwriting the orginial file
Browse files Browse the repository at this point in the history
Instead of overwriting the original file, I made a change to copy the file in the tmp folder of the iOS device.
  • Loading branch information
tonimoeckel committed Sep 27, 2018
1 parent 31f44d3 commit c67c9b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ios/RNPhotoEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
#import <iOSPhotoEditor/iOSPhotoEditor-Swift.h>

@interface RNPhotoEditor : NSObject <RCTBridgeModule>
@interface RNPhotoEditor : NSObject <RCTBridgeModule, PhotoEditorDelegate>

@end

7 changes: 5 additions & 2 deletions ios/RNPhotoEditor.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ - (void)doneEditingWithImage:(UIImage *)image {
if (_onDoneEditing == nil) return;

// Save image.
[UIImagePNGRepresentation(image) writeToFile:_editImagePath atomically:YES];
NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
NSURL *fileURL = [[tmpDirURL URLByAppendingPathComponent:[NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970]]] URLByAppendingPathExtension:@"jpg"];

_onDoneEditing(@[]);
[UIImageJPEGRepresentation(image, 0.8) writeToURL:fileURL atomically:YES];

_onDoneEditing(@[[fileURL absoluteString]]);
}

- (void)canceledEditing {
Expand Down

0 comments on commit c67c9b8

Please sign in to comment.