top of page
  • Writer's picturevignesh rajendiran

Firebase Storage - Download files

This post is a continuation of the "Firebase storage upload files" functionality. If you don't know how to upload files to Firebase, please check that post.


Firebase setup

In order to download any file we need to know where it is stored first. When we upload files to Firebase we will get the stored URL as Download URL. It will be available to us during at that particular time only and Firebase is not updating any databases for us with those details. So let's create a new collection named "UserFiles" and update it once the firebase upload function is successfully uploaded.


Creating application to download files in AppGyver

  • I am making use of the same project which is created during the upload post to have both functionality in the same application. If you are creating an application only for downloads, then maintain the Firebase project details and initialize Firebase.

  • Let's add database update logic once the file is uploaded to Firebase. I will be explaining how to just pick one file as input to upload by setting multiple files as FALSE in the pick files flow function.

  • Binding to create record flow is done using a formula similar to the one below.

outputs["Firebase Storage upload files"].files[0].downloadUrl
outputs["Firebase Storage upload files"].files[0].name
outputs["Firebase Storage upload files"].files[0].mimeType
  • Add a data resource for the new collection created in Firebase and create a data variable for it. Then, using data variables, I repeated the file item container inside Scroll view.

  • When we tap on the download icon, the respective file should be downloaded first to a temporary path and then it needs to be exported to downloads. So, there are two steps here to achieve the download function.

  • Install the Download Files flow function from the marketplace and trigger it once we tap on the download icon by binding the inputs to the respective container iteration.

  • Install the Export to Downloads flow function from the marketplace and bind the output of download files as an input to this function.

  • The complete flow logic on the download icon component tap looks like below.

  • That's it. You can now upload and download files on your device using this application.

Issues with Export to download.

When I was working with AppGyver a few months back, the same flow function worked fine, but when I am trying to download a file using the same function now, I end up with an issue. I don't see the file in my device's download folder after the success message from the Export to Download flow function.

This might have been fixed by the time you read this post by the Appgyver team. Suppose if you are facing the same issue, let me explain the issue and workaround I used to fix this.

Root cause

The file is getting downloaded to the application folder and not to the device download folder. Could not comprehend? Let me demonstrate using Appgyver and the system variable systemVars.fileSystem.directories.android.

  • According to Appgyver preview, the values of the android directory are below.

  • During runtime, the value of this system variable is not the same. Here is a quick example of download key in this directory object.

Workaround

  • Download Move/Replace file/Directory from the flow function marketplace.

  • Trigger it after Export to Downloads.

  • As you know the file path where it is getting downloaded to your device and where you want it to be downloaded, pass the Source file path and Target file path as input to Move/Replace file/Directory.

Source file path

Target file path


Suggestions and feedback are much appreciated. It encourages me to improve and share more content based on my experience with no code tools. If you have any doubts or queries, drop them in the comment section.

144 views1 comment

Related Posts

See All
bottom of page