Uppy AWS S3 Plugin

Learn how to configure the Uppy AWS S3 Plugin for use with Filebase.

What is Uppy?

Uppy is a module file uploader that fetches files from a local or external location and uploads them to a destination endpoint such as AWS S3. Uppy features a comprehensible API and a variety of modules and plugins for file manipulation and management. Uppy currently does not support Windows NPM environments. The Uppy API works closely with Transloadit.

Read below to learn how to use Uppy AWS S3 Plugin with Filebase.

Prerequisites:

1. Install the Uppy AWS S3 plugin and the Uppy Companion plugin:

npm install @uppy/aws-s3

npm install @uppy/companion

2. If using a stand-alone Uppy server, set the following environment variables:

export COMPANION_AWS_KEY="FILEBASE_ACCESS_KEY"
export COMPANION_AWS_SECRET="FILEBASE_SECRET_KEY"

# Alternative to set secret via file instead of environment variable:
export COMPANION_AWS_SECRET_FILE="PATH/TO/FILEBASE/SECRET/FILE"

export COMPANION_AWS_ENDPOINT="s3.filebase.com"
export COMPANION_AWS_BUCKET="FILEBASE_BUCKET_NAME"
export COMPANION_AWS_REGION="US_EAST_1"

Replace the following values to match your configuration:

  • FILEBASE_ACCESS_KEY: Filebase Access Key

  • FILEBASE_SECRET_KEY: Filebase Secret Key

  • PATH/TO/FILEBASE/SECRET/FILE: Path to Filebase credentials file if using a credentials file to store credentials instead of environment variables.

  • FILEBASE_BUCKET_NAME: Filebase Bucket Name

3. To use Uppy Companion with an existing server, call the server’s .app method and pass an options object as a parameter with the following code:

import express from 'express'
import bodyParser from 'body-parser'
import session from 'express-session'
import companion from '@uppy/companion'

const app = express()

const options = {
  providerOptions: {
    s3: {
      getKey: (req, filename, metadata) => filename,
      key: 'filebase-access-key’,
      secret: 'filebase-secret-key',
      Endpoint:s3.filebase.com’,
      bucket: 'filebase-bucket-name',
      region: 'us-east-1',
      useAccelerateEndpoint: false, // default: false,
      expires: 3600, // default: 300 (5 minutes)
      acl: 'private', // default: public-read
    },
  },
  server: {
    host: 'localhost:3020', // or yourdomain.com
    protocol: 'http',
  },
  filePath: 'path/to/download/folder',
  sendSelfEndpoint: 'localhost:3020',
  secret: 'mysecret',
  uploadUrls: ['https://myuploadurl.com', /http:myuploadurl2.com],
  debug: true,
  metrics: false,
  streamingUpload: true,
  allowLocalUrls: false,
  maxFileSize: 100000000,
  periodicPingUrls: [],
  periodicPingInterval: 60000,
  periodicPingStaticPayload: { static: 'payload' },
  corsOrigins: true,
}

Replace the following values to match your configuration:

  • FILEBASE-ACCESS-KEY: Filebase Access Key

  • FILEBASE-SECRET-KEY: Filebase Secret Key

  • FILEBASE_BUCKET_NAME: Filebase Bucket Name

If you have any questions, please join our Discord server, or send us an email at hello@filebase.com

Last updated