CSharp
CSharp

Reputation: 1486

Getting a list of files in a directory for uploading in ngCordova

I'm building a mobile app in Ionic. As part of the app I would like to get a list of all files in a given directory and then use something like the Cordova File Transfer plugin to upload them to a remote site.

I've been working with the Cordova File Plugin to create files on an android mobile device. And check if a specific file exists in a specific location. But there doesn't seem to be a way of listing all files in a directory. The page linked to doesn't list any such methods.

Has anyone previously coded what I'm trying to do, who can advise on the best way to go?

Upvotes: 1

Views: 1535

Answers (1)

CSharp
CSharp

Reputation: 1486

Solution found. For future reference, the ngCordova file plugin source has a listDir function that has been commented out in the version I'm using (0.1.23-alpha). Apparently, however, that function can be used according to this post on the Ionic forum. The work-around for me was to uncomment the function and add {create: false} as an option parameter to the FileSystem.getDirectory call (line 2911). Tested on an android device and it seems to work.

Upvotes: 3

Related Questions