Set condition to Component download + extension App PDF Viewer

Hello community, I have created a download button and pdf viewer, I want the following function:

When the button is clicked, I want to check in the mobile directory if the file “namefile.pdf” is stored in it; If it is stored there will be the file, otherwise, download the file and then display it.

Use any of the following extension:

1 Like

Set the Load From Storage block on When Download Complete event

And with file extension If File/Directory Exists

Edit: My mistake! the first block should also check, right?


@samidr8, I believe now it’s clearer.

2 Likes

Yes @Fabio, Thank you very much my brother, The Eternal bless you.

1 Like

There is no need to check file on download complete.
According to your blocks,
Download will only start if file doesn’t exists.

Why? Maybe internet is disconnected and extension thought download has finished, or maybe it downloaded corrupted file.

3 Likes

If so:

  • create a procedure for checking file and downloading if it does not exists
  • run procedure on screen initialization
  • if download failed run procedure again
    …this will create a loop until file gets downloaded.

Or…
Use network component and if network disconnected then pause download.

As I know there is an event block named ’ download error’ (I am very good in forgetting names :sweat_smile:) that will be triggered if download failes or comes an error

2 Likes

That was the simplest way to explain. Surely, he can leave out the check file block, and also add notifier, such as “Open PDF now? Yes No”, “Download Complete”, and so on

2 Likes

Yes there are multiple ways to do a particular thing.
Now it depends on @samidr8

2 Likes

Thank you very much for your contributions to all, sincerely I had not contemplated if a cell phone had no internet connection. The suggestions will be put into practice.

One last question, by default, is the Custom_Download component where you save the downloaded files?

In my case, it does it in the mobile memory, because I don’t have an SD card, and in the case that an expandable SD memory?

In my case I use the Application Specific Directory in the internal storage, but it can be also used in the external storage. In both cases, it’s not necessary to ask for permission.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.