breautek commented on issue #628: URL: https://github.com/apache/cordova-plugin-file/issues/628#issuecomment-2590028997
> ps. im not currently using scheme, im using the default scheme which return me using .toURL() the default file:// There are known issues surrounding using `file://` hosted applications, which was noted on the [blog](https://cordova.apache.org/announcements/2024/11/20/cordova-plugin-file-8.1.3.html) post. > I assume that folder Library/NoCache have no enaugh permission on IOS to load on DOM. > > Could you please try saving and using file as u did on https://github.com/apache/cordova-plugin-file/pull/642 but using Library/NoCache folder? WKWebKit by default (and for security reasons) will only load content within the read-only application content. That is content that is packaged shipped with the ios binary. Everything outside of this directly is considered outside of the "sandbox", which includes the app's writable data directories. The `.toURL()` returns a `file://` path with not using schemes to maintain legacy behaviour, which only valid for the legacy `UIWebView`. This method does not work on the newer `WKWebView` as explained above. If you can't switch to schemes, then using the ArrayBuffer / Blob url method is the only other way to load videos into the DOM, since you're bypassing WkWebkit restrictions at this point and it's the safest way to do that. You'll need to maintain state to determine when a particular video blob url is no longer used and can be freed to avoid memory leaks. ### Using Schemes It would be recommended to switch to schemes if possible, it has several other advantages besides enabling DOM urls. This can be done by adding the scheme and hostname preferences in your `config.xml`: ```xml <widget ...> ... <platform name="ios"> <preference name="scheme" value="app" /> <preference name="hostname" value="localhost" /> ... </platform> </widget> ``` The main things to know when switching is doing this will cause your `document.origin` to change from `null` to `app://localhost` (or whatever what you choose for the scheme). This means web storage associated with the origin will not be accessible, as you'll get a new storage container. So if you use cookies, local storage, IndexedDB, etc... these containers will effectively be reset. Technically the old data will still exists in the app's data folders but they will not be accessible by the webview. If you don't use the web storage containers then it should be pretty safe for you to switch to schemes. You're free to choose whatever scheme and hostname you like, but there is a limitation and you cannot choose any scheme that the `WKWebView` already handles. This means common protocols like http, or https cannot be used for the scheme value. If you choose an unavailable scheme, cordova will silently error and fallback to `app`. > Cause the problem of using tmp folder is that is not persistent, so when i close the app i lose all my cached data, and should be downloaded each time users would use this app The temp folder should only be cleared for 3 reasons: - The application clears the files manually - The user requests the cache to be cleared on an application - The disk storage space is so dangerously low that the OS **needs** to clear space for to function properly, in which case it will generally start clearing caches of apps that hasn't been used first. Otherwise the temp directory is persistent. Apache plugins that does data writes tends to choose the cache/temp directory because the plugin makes no assumptions and leaves it to the app to decide what it should do with the file. So if the file should be "more" persistent, then the application should move the file to the data directory using the file plugin's APIs. Do note that user's can still request app data to be cleared as well. I'm closing this issue because I believe I have a good enough understanding of your environment now and I don't believe there is a bug that Cordova can take action on. If you have further issues using `.toURL()` with schemes enabled, then a new issue can be created within that context. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org