Unable to download file from WebViewer

I am trying to make a Html Editor and I have put a download button in my webpage which downloads the code as a HTML file.

I am downloading the file using the following Javascript function:


This is able to download the HTML file in any browser but is not working in the app and showing the following error:


I am using the following way to download a file from a WebViewer as stated by @techcvr

Any help would be highly appreciated.

Look at the screen with the error says: Can only download HTTP/HTTPS url’s.
What is the address of the file you want to download ?
Check if you forgot http:// or https:// in the link

I called snackbar to show the url and here is what I found:

In this, I used FileSaver.js library

I think the problem is blob files
Read this article

1 Like

Hmm… I came accross that while browsing. But that couldn’t solve my issue either

You see this in my link ???
Blob URI/URL was created by JavaScript, refers to data that your browser currently has in memory (only in current page), and does not refer to data the exists on the host

That was when I was using FileSaver.js library. I tried saving the file by my other method and here is what I got as url:

image ( without any library )

I think that is the content of the html file and not the html file

It is working in any browser.

While downloading any file the url must start with HTTP or HTTPS otherwise it will so this error. there no other option.

1 Like

Hmm… :pensive:

try saving data:html/plain;charset=utf-8… the reult into html file, open it and look what happens

This is only what I want to achieve. :sweat_smile:

If can show the content into snackbar you can save the content into html file with file component !!!

really ?? :smiley:
How can I save a text into an HTML file ??

Of course !!!
Set File name > test.html


Where does the File component saves the file ??

Look documentation:

Saves text to a file. If the filename begins with a slash (/) the file is written to the sdcard. For example writing to /myFile.txt will write the file to /sdcard/myFile.txt. If the filename does not start with a slash, it will be written in the programs private data directory where it will not be accessible to other programs on the phone. There is a special exception for the AI Companion where these files are written to /sdcard/AppInventor/data to facilitate debugging. Note that this block will overwrite a file if it already exists If you want to add content to a file use the append block.

Check if you need add permision for that !!

I checked the docs to see that.

Does it means that the file is not accessible to the user ??

For other programs or app’s !!! only you app can access to the file