619
Views
8
Comments
File Downloading in Mobile Apps | OutSystems
Application Type
Mobile
Service Studio Version
11.53.36 (Build 61842)

Hi All,

This may be a repeating question in the forum. I tried many recommended ways, but they did not work for me, Therefore I am posting this question again. 

Requirement : My requirement is Downloading a file by giving the inputs Binary File and Its name. To get those inputs I am using an Aggregate as follows. 

  • GetLocalSupportRequestById.List.Current.LocalSRProblemAttachment.Attachment (Binary File)
  • GetLocalSupportRequestById.List.Current.LocalSRProblemAttachment.AttachmentName (Its Name)

There is a Download Widget available for Reactive web apps. But in Mobile Apps, there is no such widget. 

Therefore I tried different components in Forge implemented by some developers.

  1. File Downloader for Mobile          

This component is ideal for my requirement. I just gave the above 2 inputs and tried with the default OutSystems emulator. It worked fine, and the Binary file (I tried .jpg, .pdf, .txt and many more) got downloaded. But the saddest thing is, when I installed the app in my mobile, the file did not get downloaded. I gave all the permissions it asked (Files and Media/ Camera) too. My android version is 12. 

2.   File Download Mobile

I tried this too. It is actually not suitable for my requirement. The reason is that it automatically downloads the file when the user redirects to the specific screen. We cannot use a button there and add the logic. And also as in "File Downloader for Mobile" component, when the mobile app is installed in the mobile phone, it did not work.

3. FileDownloader

I tried to use this too. But when this forge component is installed in the service studio, it asks to resolve dependencies. When I refresh and apply those, the FileDownloader itself give many errors as follows. Therefore I did not try it further.

4. File Transfer Plugin 

I tried to use this plugin too. But it asks some server URLs and File system URLs. I actually need to input the Binary file and its name to make it downloaded. 

I am an OutSystems beginner. Could you please help me to implement this usecase? 

2025-04-17 05-42-16
Ajit Kurane

Hi,

I know you have tried hard to get it done.

Can you please give a try to the below forge componet,

https://www.outsystems.com/forge/component-overview/8322/fileviewerdemo

As well please check below thread if you haven't gone through,

https://www.outsystems.com/forums/discussion/72434/does-anyone-have-a-step-by-step-to-download-file-via-mobile-app/

Thanks.

UserImage.jpg
Jithmi Perera

Hi Ajit,

Thank you very much for your response and recommended options. 

We tried to proceed with File Viewer Demo Forge Component. When we tried to install it, It says that  "File Viewer Demo" is not compatible with following dependencies. 

By the way, we have installed the latest versions of "Outsystems UI" and "File Viewer Plugin" as follows. There are no any upgrade to do. 

Therefore, We had to force install the "File Viewer Demo" component. Then it asked to Manage dependencies as follows. 

After we did manage dependencies (Refresh all and Apply), it gives 15 errors as follows. 

Therefore we did not proceed with "File Viewer Demo" component.

We are still following the provided discussion thread and let you know the progress. Thanks again for helping us.


2025-06-28 01-52-12
Marco Mateo

Hi Jithmi, 

try this plugin https://www.outsystems.com/forge/component-overview/12444/native-save-file-dialog-plugin

UserImage.jpg
Jithmi Perera

Hi Macro,

Thank you for your suggestion. I tried this plugin. I could download the file (save) in my mobile device, But the file format cannot be opened. 

I will mention the steps I followed. 

1. I added an onclick action to the button and created its logic as follows. 


2. I added JavaScript widget and added following custom JS code to encode the Binary file into Base64 format, as the Native Save File Dialog Plugin asks the file content as an input in Base64 format.

//Encode the Binary file into Base64 and assign it to output text

$parameters.Base64 = btoa($parameters.BinaryFile)


3. Then I gave the following inputs (File name and Content) to SaveFile_Any action as follows. As my requirement is to download any type of file (pdf, jpeg, etc.), I did not mention the FileType here.

4. Finally I tried this in Outsystems default emulator (Publishing and Open in browser) it gave me following error message.

5. But when I generated the Android app and install it in my mobile phone, the file was getting saved as follows.

6. But the issue is that it cannot be opened, The file in the database is a pdf file. (Jithmi.pdf). But after downloading its format is wrong.


Can you please give me any clue to resolve this issue? 

Thanks

2025-06-28 01-52-12
Marco Mateo

have you tried removing the "(4)" in your filename. The number is being added automatically if you have multiple files with same name. 

After that, you can try installing some pdf reader app to view files or if you have a built in one, you can also use it.  


Also, regarding "the cordova not defined" error. This is encountered when you are testing using emulator. try generating the app and test it on an actual phone

UserImage.jpg
Jithmi Perera

Hi Marco,

Thank you for your reply. 

Yes, I tried removing 4 also. It was automatically added to the end of the file name, as I have downloaded 3 files of the same before. (As I tried to test the file download button again and again)


I have already installed a pdf reader app to view files. All other pdf files can be opened and viewed. 

This is an issue with the format of the downloaded file using the button in the above-mentioned mobile app. Files are downloaded in wrong format. I was thinking whether I have configured the following inputs incorrectly, "especially the ContentBase64 and I have not given any specific FileType".

The JavaScript code used to encode the Binary file into Base64 . 

//Encode the Binary file into Base64 and assign it to output text

$parameters.Base64 = btoa($parameters.BinaryFile)

Could you please give me some answer?

UserImage.jpg
Jithmi Perera
2025-02-10 10-33-35
Mostafa Hammad

Did you get an effective answer to this situation? 


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.