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:

1
export COMPANION_AWS_KEY="FILEBASE_ACCESS_KEY"
2
export COMPANION_AWS_SECRET="FILEBASE_SECRET_KEY"
3
4
# Alternative to set secret via file instead of environment variable:
5
export COMPANION_AWS_SECRET_FILE="PATH/TO/FILEBASE/SECRET/FILE"
6
7
export COMPANION_AWS_ENDPOINT="s3.filebase.com"
8
export COMPANION_AWS_BUCKET="FILEBASE_BUCKET_NAME"
9
export COMPANION_AWS_REGION="US_EAST_1"
Copied!
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:

1
import express from 'express'
2
import bodyParser from 'body-parser'
3
import session from 'express-session'
4
import companion from '@uppy/companion'
5
6
const app = express()
7
8
const options = {
9
providerOptions: {
10
s3: {
11
getKey: (req, filename, metadata) => filename,
12
key: 'filebase-access-key’,
13
secret: 'filebase-secret-key',
14
Endpoint: ‘s3.filebase.com’,
15
bucket: 'filebase-bucket-name',
16
region: 'us-east-1',
17
useAccelerateEndpoint: false, // default: false,
18
expires: 3600, // default: 300 (5 minutes)
19
acl: 'private', // default: public-read
20
},
21
},
22
server: {
23
host: 'localhost:3020', // or yourdomain.com
24
protocol: 'http',
25
},
26
filePath: 'path/to/download/folder',
27
sendSelfEndpoint: 'localhost:3020',
28
secret: 'mysecret',
29
uploadUrls: ['https://myuploadurl.com', /http:myuploadurl2.com],
30
debug: true,
31
metrics: false,
32
streamingUpload: true,
33
allowLocalUrls: false,
34
maxFileSize: 100000000,
35
periodicPingUrls: [],
36
periodicPingInterval: 60000,
37
periodicPingStaticPayload: { static: 'payload' },
38
corsOrigins: true,
39
}
Copied!
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 [email protected]