Seam Miniapp Maker
  • Creating Miniapps on Seam
  • Get Started
    • Quickstart
    • Local Environment Setup
  • Miniapp Creation
    • Composer Component
    • Feed Component
    • Supporting Mobile
    • Uploading Images, Videos, and Files
    • Miniapp Icons
    • FAQ
    • Tips & Tricks
  • Submission
    • Creating a Pull Request
    • Adding Teammates
Powered by GitBook
On this page
  1. Miniapp Creation

Uploading Images, Videos, and Files

PreviousSupporting MobileNextMiniapp Icons

Last updated 9 months ago

If your miniapp involves allowing users to upload files, Seam provides a storage bucket for our miniapp file upload and storage. This allows you to upload any file (image, video, sounds, 3d images) and not worry about hosting your own backend. Additionally, you can use this simulated testing enviroment when you build you miniapp, without needing to upload to a real server.

Getting started: Setting up Firebase locally

To get started uploading files, you'll need to run a local server to simulate the process of uploading and downloading files. Open up a new terminal at your Miniapp Builder SDK directory and run the following command:

npx firebase emulators:start

Then, you can see a sample file upload bucket at http://127.0.0.1:4000/storage/demo-seam-miniapp-builder/files.

Uploading Images

To upload images in your miniapp, you can use the FileUploadComponent provided to you by Seam, like so:

import FileUploadComponent from './utils/FileUploadComponent';

const handleUpdate = (uploadedUrls: string[]) => {
    setPreviewUrls(uploadedUrls);
};

<FileUploadComponent
    fileTypes="image/*"
    label={previewUrls.length > 0 ? "Upload More Images" : "Upload Images"}
    onUpdate={handleUpdate}
    multiple={true}
    maxFiles={10}
/>

This gives you a button that when clicked allows the user to pick photos from their camera roll. Check out the ImageComposerComponent for a full example.

Uploading Videos

To upload videos in your miniapp, you can use the same FileUploadComponent, but specify a fileType of video, like so:

import FileUploadComponent from './utils/FileUploadComponent';

const [uploadedUrl, setUploadedUrl] = useState(model.data['url'] || "");

const handleUpdate = (urls: string[]) => {
    if (urls.length > 0) {
      setUploadedUrl(urls[0]);
      model.data['url'] = urls[0]; // Only one video is allowed
    }
};

<FileUploadComponent
    fileTypes="video/*"
    label="Upload a Video"
    onUpdate={handleUpdate}
    multiple={false}
    maxFiles={1}
/>

This gives you a button that when clicked allows the user to a video from their camera roll. Check out the VideoBlock for a full example.

Uploading arbitrary files

Troubleshooting

For any other file types, you can use the Firebase uploader functions yourself. Read more in the . The strategy is 1) use the upload component to upload, and then 2) store the URL in your block.

If you get the error: Error: firebase-tools no longer supports Java version before 11. Please upgrade to Java version 11 or above to continue using the emulators., you unfortunately need to download a new version of the JDK (Java Development Kit). Go to the , download the installer, and try starting the emulators again.

Firebase
documentation here
Oracle JDK Download page