# File Upload / Download / Viewing

**URL:** <https://community.thunkable.com/t/file-upload-download-viewing/637019>\
**Category:** Questions about Thunkable X\
**Created:** [June 25, 2020, 5:33pm UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019 "2020-06-25T17:33:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![av8](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@av8](https://community.thunkable.com/u/av8)\
**Post date:** [June 25, 2020, 5:33pm UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019/1 "2020-06-25T17:33:15Z")

</div>

Hi, I’ve tried to find the answer to this elsewhere but haven’t been successful; I’m hoping someone can kindly help me.

I am trying to create an app where a user logs in and can view PDF files specific to them. I’ve created the user login process (using Firebase) and have created: Authentication, RealTime Database and Storage.

The first two work fine to login / logout and to retrieve text data. I now need a user to be able to retrieve files specific to them which have already been added to their record (not generic URL files that anyone can see).

Is this possible? If not possible to directly connect my app with the storage database, is it possible to connect a field in my realtime database with the url of a file in my storage? That way I can set the field to display the url of the file and clicking it would then show.

Many thanks in advance of any help  
Jon

---

<div class="post-metadata">

**Author:** ![athornock](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@athornock](https://community.thunkable.com/u/athornock)\
**Post date:** [June 25, 2020, 9:37pm UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019/2 "2020-06-25T21:37:16Z")

</div>

Yes, just put the url in your realtime db under the users email address. For example you’re json to send to firebase would be something like {email:{“fileName”:“lkjdsflkjcikjl”,“fileUrl”:“[www.url.com](http://www.url.com)”,“date”:“6/25/20”}} (assuming email is your variable).

Then when you retrieve it you’ll retrieve the email key.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/d/5d33bd66100281178f94a47e968108500ad7ba70.png)

---

<div class="post-metadata">

**Author:** ![av8](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@av8](https://community.thunkable.com/u/av8)\
**Post date:** [June 26, 2020, 2:44pm UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019/3 "2020-06-26T14:44:39Z")

</div>

Hi

Thanks very much for replying to my post. I’m really new to both Thunkable and programming, so my follow up questions might be a little basic (apologies).

The tutorials I’ve been watching so far has my realtime db set up so that data is stored under the user’s UID (which is common to both the authentication and the realtime). As a test, I’ve created a structure in my realtime db of:

 ![1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/3/23f5fa8df2ecb731ccef57e8e5fd03a58dec6d55.png)

I can then “get” that data using a key that has the above structure.

I’m going to set aside how I get the storage url into the Test\_Data\_Field for the moment, and just assume that its already there (manually added a test PDF). I’m not sure what to do next. Is there a function in Thunkable that will read the url and allow the user to tap it in order to view? I re-created the block you kindly added (above) but then didn’t know what to do with it. Does it connect to the PDF viewer in some way?

I’m likely to be missing something (or many things!) here; if you could dumb it down for me, that would be greatly appreciated 🙂

Best  
Jon

---

<div class="post-metadata">

**Author:** ![athornock](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@athornock](https://community.thunkable.com/u/athornock)\
**Post date:** [June 26, 2020, 6:39pm UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019/4 "2020-06-26T18:39:16Z")

</div>

Based on your data structure (assuming the ‘AySHtKT…’ is your key) it would look like this:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/5/c5af45afdba541e7eeb5213fe1d2370b8daf1e2a.png)

If your key is actually generated by firebase then you may have to search for the user\_email, which is a bit more involved with that data structure (and not recommended by me). Just as long as you know that key you should be good.

---

<div class="post-metadata">

**Author:** ![athornock](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@athornock](https://community.thunkable.com/u/athornock)\
**Post date:** [June 26, 2020, 6:41pm UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019/5 "2020-06-26T18:41:55Z")

</div>

Also, another point just to save you some headache as you work through this process: if your data object comes back null and you try to use it it will stop your app at that point. So I usually put in some logic to make sure ‘data’ is not null. Something like this:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/d/ddb33e691bf254a06b94b7d3deb48e52b68336ca.png)

---

<div class="post-metadata">

**Author:** ![av8](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@av8](https://community.thunkable.com/u/av8)\
**Post date:** [June 29, 2020, 10:57pm UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019/6 "2020-06-29T22:57:33Z")

</div>

Hi, thanks very much for the advice. I think I’ll have to have a play around with it in order to understand what to do. My knowledge gaps seem to be how to connect in with Firebase’s authenticatio, its storage and the realtime db so the app will get Thunkable to log the user in, but then connect data from the realtime db and files from storage.

If you have any advice on how the firebase authentication with its user ID and email can link in with its realtime db, it would be very gratefully received. My problem is less the fact that I don’t know the answers, its more I don’t know the right questions to ask ☹

This might take me a while!

Best  
Jon

---

<div class="post-metadata">

**Author:** ![av8](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@av8](https://community.thunkable.com/u/av8)\
**Post date:** [June 29, 2020, 10:59pm UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019/7 "2020-06-29T22:59:50Z")

</div>

Just a quick question; for the the block you created above, which component is that added to?

---

<div class="post-metadata">

**Author:** ![athornock](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@athornock](https://community.thunkable.com/u/athornock)\
**Post date:** [July 1, 2020, 2:31pm UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019/8 "2020-07-01T14:31:25Z")

</div>

The block I created (the purple block) is a function so it can be added anywhere that you need to get that url. In fact there’s a function block with a “return” feature also that you could use to return the app url and then you just plug in that function block anywhere you need to get the Url.

I’d probably turn you to the official documentation first. [https://docs.thunkable.com/](https://docs.thunkable.com/)

Some specific guides: [https://docs.thunkable.com/sign-in-1](https://docs.thunkable.com/sign-in-1) for sign in.

Functions: [Functions - ✕ Docs](https://docs.thunkable.com/functions)

Keep in mind that the documentation hasn’t been updated to include the newer “cloud” blocks for firebase. They are definately the way to go and it seems like you’ve already figured out how to use those for the most part.

To use firebase effectively you’ll really need to figure out the data structure and the difference between objects and lists. If you upload a list to firebase for example it will assign numbers.

If you want to search by user email then you’ll want to adjust your structure to something like:

USERS  
–\>email  
------\>user data

So you’ll be uploading to a path like this:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/c/4c68bac63d97ce0a15b6e774c25d3cc370b4996a.png)

There’s a little bit of a learning curve, but far less than programming languages.

The best thing to do is just play around with it and keep diving into the documentation until you see the outcomes you want.

There’s also a tutorial section [https://docs.thunkable.com/get-started/tutorials](https://docs.thunkable.com/get-started/tutorials)

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:25am UTC](https://community.thunkable.com/t/file-upload-download-viewing/637019/9 "2024-11-08T11:25:13Z")

</div>


