4

I am currently working on an old iOS app. I don't have much idea about cordova.

I am stuck at one place, where code uses window.requestFileSytem . There is some code in success callback of this function.

When I debug, I found that success callback is not triggered. I am not able to find any thing about this function in latest cordova document however there is some thing in older document.

So I am worrying about is window. requestFilesystem method is deprecated. If so then how can I achieve same thing in latest cordova.

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onReqFileSystemSuccess, null);

Any help would be appreciated.

Kenny
  • 5,407
  • 4
  • 19
  • 37

2 Answers2

3

Reviewing @iammilinds answer I have to correct my initial statement:

The window.requestFileSystem method is non-standard and should not be used. See the linked MDN docs.

Yet there are code examples containing the window.requestFileSystem method in the documentation for the cordova file plugin here or here (searching for window.requestFileSystem might help as the dcos are pretty large).

So regarding your initial problem: I'm afraid you'll have to debug it. Maybe checking the browser's console might give you a hint what's wrong. Or try to add an error handler to window.requestFileSystem as the last parameter like so:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onReqFileSystemSuccess, onErrorLoadFs);
Phonolog
  • 6,121
  • 3
  • 32
  • 63
1

Yes, it's deprecated.
It's implemented only by Chrome as of today.

This is what Mozilla page for Window.requestFileSystem() for this API says:

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

Above notice can be seen for several other "Files & Directories" APIs. However, below notice is significant and is read only for this particular API.

Even compared to the rest of the File and Directory Entries API, requestFileSystem() is especially non-standard; only Chrome implements it, and all other browser makers have decided that they will not implement it. It has even been removed from the proposed specification. Do not use this method!


The correct usage is as discussed in this post: How to use window.requestFileSystem of FileSystem API?

window.requestFileSystem = window.requestFileSystem ||  // Chrome
                           window.webkitRequestFileSystem;  // Others
iammilind
  • 65,167
  • 30
  • 162
  • 315
  • The question was not about the browser API, but the Cordova Plugin File API that uses the same signature (and was written before the HTML 5 browser API was implemented). – janpio Jun 07 '19 at 12:45