🚀 Add File Downloads
Finally, you'll add the ability for users to download the files they've uploaded. The app will look up the file's location in Firestore, get a download link from Storage, and open it for the user.
→ In the AI Studio "Code assistant" prompt box, enter the following instructions (as heard in the audio and seen on-screen):
Add download file functionality. When a user downloads a file, find the storage path from in Firestore files/{fileId}(storagePath) and get the download url. When you get the url, open it in a new tab.
→ Send the prompt to the AI assistant.
Test the Download Functionality
- Test the Download:
- In your app preview, log in.
- Click on any file you have previously uploaded (e.g., "My Profile Photo.png").
- In the file details pane on the right, you will now see a "Download" button.
- Click the "Download" button.
- Verify the Result:
- A new browser tab will open, displaying the full-size image or file.
- From here, you can right-click and save the image to your computer.
Your app now has a complete file-handling loop: upload, store, and download!