apache / cordova-plugin-camera

Apache Cordova Plugin camera
https://cordova.apache.org/
Apache License 2.0
960 stars 1.52k forks source link

Try to use realpath filename instead of default modified.jpg #99

Closed nantunes closed 8 years ago

schreyers commented 8 years ago

Hi Nantunes,

Did you manage to use the realpath filename and if sodo you know when it will be added to the npm version on phonegap? There is a current bug which means images get uploaded as duplicates because of the file name still being modified.jpg for all the edited images.

https://stackoverflow.com/questions/30438483/cordova-image-upload-duplicate-issue#

I have recently re-added the plugin but I still get the issue that edited images are called modified.jpg.

Thanks, Jon

nantunes commented 8 years ago

Hi @schreyers

I'm still using my forked version, as this PR hasn't been merged (or even reviewed).

If it is critical to your project, you probably better applying this fix yourself.

schreyers commented 8 years ago

Thanks @nantunes

I'll make your changes to the files and remove the source="npm" from my config file.

schreyers commented 8 years ago

Hi @nantunes

Quick question. Are you able to use your forked version when using build.phonegap.com? If not how are you using your changes?

Thanks in advance,

nantunes commented 8 years ago

I'm using the lastest versions of cordova with ionic framework. I build locally. No phonegap-build, so I can't tell.

schreyers commented 8 years ago

Sorry for the delayed reply. Have been trying to build locally but i get loads of errors.

I really need this to be fixed in the npm version of the plugin.

vladimir-kotikov commented 8 years ago

@nantunes, thanks for contribution. Could you please rebase your changes.

Also please file an Apache CLA as described in CONTRIBUTING.md

nantunes commented 8 years ago

Ok, will do it this night.

nantunes commented 8 years ago

Rebased and ICLA sent by email.

vladimir-kotikov commented 8 years ago

Yep, see it now. Merging. Thanks for contribution, @nantunes!

FuzzyTree commented 8 years ago

Has anyone tested this patch? Applying the changes to CameraLauncher.java results in failed getPicture calls. Unfortunately the only error is "Error retrieving image", so I'm not sure where it breaks.

I also tried building from the nightlies and get the same error. When I revert ouputModifiedBitmap in the nightlies the error goes away.

nantunes commented 8 years ago

Per se the patch only manipulates strings:

String fileName = realPath != null ?
    realPath.substring(realPath.lastIndexOf('/') + 1) :
    "modified." + (this.encodingType == JPEG ? "jpg" : "png");

String modifiedPath = getTempDirectoryPath() + "/" + fileName;

So I don't how could it cause that error. Maybe some other change in-between? Could you diff the two versions of CameraLauncher.java?

FuzzyTree commented 8 years ago

Debugging shows that FileHelper.getRealPath returns an empty (non-null) string, which causes the function to return a directory name instead of a file name.

/storage/emulated/0/Android/data/com.ionicframework.ws938141/cache: open failed: EISDIR (Is a directory)

    // Some content: URIs do not map to file paths (e.g. picasa).
    String realPath = FileHelper.getRealPath(uri, this.cordova);
    // Get filename from uri
    String fileName = realPath != null ?
        realPath.substring(realPath.lastIndexOf('/') + 1) :
        "modified." + (this.encodingType == JPEG ? "jpg" : "png");

Adding a check for empty string fixed the issue for me

String fileName = (realPath != null && !realPath.isEmpty()) ?

and

 if (realPath != null && !realPath.isEmpty() && this.encodingType == JPEG) {
shraddha-khalekar commented 4 years ago

that issue is still there in camera plugin

shraddha-khalekar commented 4 years ago

can someone plz tell how to solve this issue for ionic 4

janpio commented 4 years ago

Please open a new issue and fill the template instead of abusing an old and already merged PR.