Skip to main content

File upload

Marblism includes a system for uploading both public and private files.

Server > Upload Library

apps/server/src/libraries/upload

The library contains two providers.

Local Provider

The default provider stores files on the server's disk.

This is intended for local development only and is not recommended for production use.

AWS S3 Provider

Integration with AWS S3 buckets.

Steps for activation:

  • Sign up to AWS
  • Create a set of access and secret keys
  • Create a public S3 bucket for public files (e.g., my-app--public). You can watch this 2-minute tutorial.
  • Create a private S3 bucket for private files (e.g., my-app--private).
  • Add your variables to the apps/server/.env file:
SERVER_UPLOAD_AWS_ACCESS_KEY=
SERVER_UPLOAD_AWS_SECRET_KEY=
SERVER_UPLOAD_AWS_BUCKET_PUBLIC_NAME=
SERVER_UPLOAD_AWS_BUCKET_PRIVATE_NAME=
SERVER_UPLOAD_AWS_REGION=

Server > Upload Module

apps/server/src/modules/upload

This module defines three endpoints to interact with the Upload library:

POST Public File

Uploads a public file and returns a URL with no expiration time.

POST Private File

Uploads a private file and returns a protected URL.

POST Private to Public url

Transforms a protected URL into a public URL, valid for one hour.

Upload API

apps/web/src/domain/upload

API calls are predefined and ready for use in your app.

Tips

  • Use the public upload for non-sensitive information such as logos, or blog post pictures.
  • Use the private upload for sensitive information that requires protection.
  • Although we expose the Private to Public URL endpoint for simplicity, consider hiding it and handling the creation of public URLs for private files directly on your server for enhanced security.