eight-labs/formbase

File Upload

Closed this issue · 2 comments

File Upload

Okay I want to take this but, I need some briefing

When a form is submitted, at the backend, we retrieve the file with the FormData Object. Then the file is uploaded to an aws s3 sdk compatible storage. The idea was supabase initially but looks like supabase storage does not support aws s3 so the option is to look for another provider. Either selfhost with minio or use Cloudflare R2. You can test with minio locally, add this to the docker compose.

  minio:
    image: minio/minio
    container_name: formbase_minio
    ports:
      - 9002:9002
      - 9001:9001
    volumes:
      - minio:/data
    environment:
      MINIO_ROOT_USER: formbase
      MINIO_ROOT_PASSWORD: password
    entrypoint: sh
    command: -c 'mkdir -p /data/formbase && minio server /data --console-address ":9001" --address ":9002"'

After successfully uploading the file to the cloud storage bucket, you will receive a unique reference or URL for the uploaded file and store this file reference along with other form data in the database.

When displaying the form submissions in a table, retrieve the file references from the database and use the file references to generate download links or display the files in the appropriate format. When the user clicks on a file link, you can either initiate a download or open the file in a new tab/window using the file reference URL.

Other Side stuff we can take care of later

  1. When a use exports a table, all the files, if any should be zipped and downloaded as well
  2. We currently support both multipart/form-data, which is easier to handle and application/json. For now, file uploads should only be for when a user uses form data. Let's worry about JSON later.

Let me know if you have any questions