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

File api is incomplete (e.g. getFreeDiskSpace, writeFile) and docs is incomplete (e.g. readAstext) #552

Closed
jgw96 opened this issue Sep 15, 2016 · 4 comments

Comments

@jgw96
Copy link

jgw96 commented Sep 15, 2016

From @dragGH102 on September 14, 2016 15:34

I'm using Ionic 2 latest beta (37) and trying to work with files (File plugin @ ionic-native).

Some methods (readDire, writeDir, ...) work normally.
However others are either missing (not implemented as per also in the Typescript definitions), for example:

  • getFreeDiskSpace
  • writeFile

or lacking a proper documentation. For example...

I understand this is still a beta but I was wondering if this is intentional of a "work in progress" (in which case feel free to close this issue)?
Thank you

Copied from original issue: ionic-team/ionic-framework#8080

@ghenry22
Copy link
Contributor

Actually getfreediskapace is implemented in the native code but has no JavaScript interface in the plugin itself, been this way forever, you can run a Cordova.exec command to access the native function, this could be implemented in the ionic native wrapper I guess

@ghenry22
Copy link
Contributor

ghenry22 commented Sep 27, 2016

This is all that is required and it could be implemented in the ionic-native wrapper for the getFreeDiskSpace call. The platform detection is to adjust the returned result to be in a consistent format on both android and ios.

//file plugin has no js interface to getfreediskspace method
//use cordova.exec directly to access it.
  getFreeDiskSpace(): number {
    var freeDiskSpace: number;
    cordova.exec(function(result) {
      //console.log(result);
      if(isAndroid){
        freeDiskSpace = (result*1024);
      }
      if(isIos){
        freeDiskSpace = result;
      }
      return freeDiskSpace;
    }, function(error) {
      //console.log(error);
    }, "File", "getFreeDiskSpace", []);
  }

ihadeed added a commit that referenced this issue Oct 12, 2016
@ihadeed
Copy link
Collaborator

ihadeed commented Oct 12, 2016

@ghenry22 thanks for suggestion, just implemented this. However, I'm just returning back the raw response from the native code, not modifying anything based on platform.

@ihadeed
Copy link
Collaborator

ihadeed commented Oct 12, 2016

@dragGH102 @ghenry22 Can you try with the latest version v2.2.2 and report back if you still have any issue? Thanks.

@ihadeed ihadeed closed this as completed Oct 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants