Upload files to your own S3 bucket

View Markdown

Introduction

You can upload files to your own S3 bucket using ittybit.


Upload task

You can create a new upload task with type: 's3' to upload a file to your own S3 bucket.

const task = await ittybit.tasks.create({
  file_id: 'file_abcdefgh1234',
  kind: 'upload',
  connection: {
    kind: 's3',
    bucket: 'your_bucket',
    region: 'your_region',
    endpoint: 'your_endpoint',
    access_key_id: 'your_access_key_id',
    secret_access_key: 'your_secret_access_key',
  },
  filename: 'your_filename.mp4',
  folder: 'your_folder',
});

Credentials

Each object storage provider has a slightly different way of fetching your credentials, but the values you need are:

  • access_key_id
  • secret_access_key
  • endpoint
  • bucket

You can usually find these values in the object storage provider's dashboard. Asking your favourite LLM or Google usually gets you there pretty quickly.


Environment variables

It's clunky to pass these credentials to your code every time you run a task. So you can save them to a secure environment variable inside ittybit.

Saving credentials

  1. Go to your project settings in the ittybit webapp.

  2. In the 'Environment variables' section, create a new variable called S3_CONNECTION_JSON.

  3. Paste your complete credentials JSON into that variable.

It should look something like this:

{
  "access_key_id": "your_access_key_id",
  "secret_access_key": "your_secret_access_key",
  "endpoint": "your_endpoint",
  "bucket": "your_bucket"
}

Using credentials

const task = await ittybit.tasks.create({
  file_id: 'file_abcdefgh1234',
  kind: 'upload',
  type: 's3',
  connection: '{{ env.S3_CONNECTION_JSON }}',
});

On this page