0

I have a file named index.html in assets folder. We are reading this file and writing it to BBD Secure storage using File class wrapper(FileOutputStream) provided by BBD.

Code for writing it to BBD secure storage,

com.good.gd.file.FileOutputStream("index.html").apply {
            write(inputStream.readBytes())
            close()
        }

This is encrypting the file content and storing it inside app_data folder also the file name is encrypted by BBD secure storage.

We read the stored file as follows,

loadUrl(GDFileSystem.getAbsoluteEncryptedPath("index.html"))

The above code is able to locate the encrypted file which was stored earlier and when we tried to load this in BBDCordovaWebView we get net::ERR_ACCESS_DENIED

1 Answers1

0

BBDCordovaWebView does not support the loading of local files using file:///..., so it is not possible using that method.

But you could load and read the file using the cordova-plugin-bbd-file API.

  1. Create the file using cordova-plugin-bbd-file API.
  2. Write HTML content to it using same plugin when app loads.
  3. Read this file at some point using same plugin.
  4. Update the DOM using file content.
MSohm
  • 815
  • 6
  • 11
  • Thanks for your response. In my case i need to load the html files in run time, initially i will be loading these files from my assets folder itself then if i have any updated versions of this html file i will download it from server and have it in my local, in this case i'm trying to load the html files from internal storage. (In android it is restricted to modify assets folder in run time as it is part of the binary so we can can't have the updated html files in assets location) – Balaji Sureshbabu Jun 05 '22 at 13:05
  • You read the downloaded file from secure container using the BlackBerry Dynamics File plugin and update root HTML with what was read on the fly. – MSohm Jun 06 '22 at 18:55
  • We created a copy of index.html inside secure container and tried loading from secure container. We could see the file created inside app_data folder which is encrypted(both file name and file data) still we are getting net::ERR_ACCESS_DENIED error. Could you please help on this? – Balaji Sureshbabu Jun 23 '22 at 11:13
  • Can you add a code snippet to your main post that shows how you store and read the file? – MSohm Jun 24 '22 at 12:13
  • Have updated the main post, please let me know for any queries. Thanks – Balaji Sureshbabu Jun 27 '22 at 07:40
  • I've updated my answer based on that. You should be able to handle this scenario all in JavaScript. – MSohm Jun 27 '22 at 14:06
  • Can you please add the code snippet for this approach which will be useful for us. – Balaji Sureshbabu Jun 28 '22 at 15:27
  • Usage of cordova-plugin-bbd-file https://github.com/blackberry/BlackBerry-Dynamics-Cordova-Plugins/tree/file is similar to the original cordova-plugin-file. You can find samples to write and read files here: https://github.com/apache/cordova-plugin-file#writeFile – MSohm Jun 28 '22 at 18:45
  • I believe using the plugin to read and write file and update the DOM using file content, we can load static html content. But in our case we have an entire application built on html, js and css. We load js and css files from index.html file. Is it possible to load all related js and css files? Please guide. – Balaji SS Jun 29 '22 at 09:53
  • If you replace the entire page, the CSS and JS referenced in that page should be loaded. This post has an example: https://stackoverflow.com/questions/4292603/replacing-entire-page-including-head-using-javascript – MSohm Jun 29 '22 at 13:09
  • In our case we have lot of JS and CSS files to be loaded and having those in a one single class is not feasible. Can you please help us to achieve this. Thanks – Balaji Sureshbabu Jun 30 '22 at 13:55
  • The new HTML could reference your JS and CSS in multiple files. Those don't have to be in a single file. Is there a problem when you reference them in multiple files? – MSohm Jul 04 '22 at 13:18