disusered / cordova-safe

File encryption for Cordova.
MIT License
35 stars 22 forks source link

error code 1 on encrypt #7

Closed bgrayburn closed 8 years ago

bgrayburn commented 8 years ago

So i've got the lib up and in the dom in android, but I'm consistently getting an error code 1 when running encrypt.

here's my code:

Meteor.enc.safe.encrypt = (fn)->
  console.log "about to encrypt: "+fn
  success = (encryptedFile) ->
    console.log 'Encrypted file: ' + encryptedFile
    return
  error = (c)->
    console.log 'Error with encryption operation, code: ' + c.toString()
    return

  Meteor.enc.safe.safe.encrypt fn, "someKey", success, error

I'm recording a video using the cordova-plugin-media-capture plugin then using the cordova-plugin-file plugin to resolve the fileEntry object. From that I've tried calling the above with:

-the fileEntry.nativeURL property (ex. "file:///storage/emulated/0/DCIM/Camera/VID_20150806_122744.3gp") -the fileEntry.fullPath property (ex. "/DCIM/Camera/VID_20150806_122744.3gp") -the fileEntry.toInternalURL() path (ex. "cdvfile://localhost/persistent/DCIM/Camera/VID_20150806_123214.3gp")

didn't really expect the last one to work but figured I'd try. All of these return an error code 1. Any idea what might be going on? I expected the nativeURL to be the right thing to pass, but no luck.

disusered commented 8 years ago

Looks like permissions issues with the Java plugin. I made some assumptions about storage that don't always hold up. I'm reading up docs and am working on a solution now!

bgrayburn commented 8 years ago

you're awesome, thank you!

disusered commented 8 years ago

I wrote some manual tests to replicate the issue, I made some progress and will continue tomorrow. Thanks again for the feedback!

bgrayburn commented 8 years ago

thanks, let me know if I can provide any assistance

disusered commented 8 years ago

I just pushed an update to address issues with finding files, the Java code is now using a core Cordova method to normalize paths. In a future update I will try to detect file objects directly as well. Hope this addresses your issue, if not let me know and we'll try something else :+1: