The /s3/store Robot

Transloadit is happy to export to whatever storage solution suits you best.

The /s3/store Robot exports encoding results to Amazon S3.

Parameters

Name Type Default Description
bucket (required) String The name of the bucket to which the file is exported.
key (required) String Your Amazon access key ID
secret (required) String Your Amazon secret access Key
bucket_region String "us-east-1" The AWS region that your S3 bucket is in. If not provided, Transloadit will figure that out for you at some speed cost.
path String "${unique_prefix}/${file.url_name}" The path at which the file is to be stored. This may include any available Assembly variables.
url_prefix String "http://{bucket}.s3.amazonaws.com/" The URL prefix used for the returned URL, such as "http://my.cdn.com/some/path".
acl String "public-read" The permissions used for this file. This can be "public-read", "public", "private" or "bucket-default".
headers String { "Content-Type": file.mime } A JavaScript object containing a list of headers to be set for this file on S3, such as { FileURL: "${file.url_name}" }. This can also include any available Assembly variables. Here you can find a list of available headers.
host String "s3.amazonaws.com" The host of the storage service used. This only needs to be set when the storage service used is not Amazon S3, but has a compatible API (such as hosteurope.de).
no_vhost Boolean false Set to true if you use a custom host and run into access denied errors.
sign_urls_for Integer / Boolean(false) false If set to a number this parameter provides signed urls in the result JSON (in the signed_url and signed_ssl_url properties). The number that you set this parameter to is the url expiry time in seconds. If set to false no url signing is done.

Example use cases

Our /s3/store Robot can be used in combination with other Robots, to create powerful workflows unique to your use case.
Here are a few example scenarios, and the required the Assembly Instructions to implement them.
You can also try demos of these examples right here, live on our website.

Encode a video, extract 8 thumbnails and store everything in your S3 bucket

{
  "steps": {
    "ipad_encoding": {
      "use": ":original",
      "robot": "/video/encode",
      "ffmpeg_stack": "v2.2.3",
      "preset": "ipad-high",
      "width": 640,
      "height": 480
    },
    "extracted_thumbs": {
      "use": "ipad_encoding",
      "robot": "/video/thumbs",
      "result": true
    },
    "store": {
      "robot": "/s3/store",
      "use": [
        "ipad_encoding",
        "extracted_thumbs"
      ],
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Store uploaded files in your Amazon S3 bucket

{
  "steps": {
    "store": {
      "use": ":original",
      "robot": "/s3/store",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Transparently extract uploaded archives

{
  "steps": {
    "archives": {
      "use": ":original",
      "robot": "/file/filter",
      "accepts": [
        [
          "${file.mime}",
          "regex",
          "application/(rar|x-7z-compressed|x-cab|x-cpio|x-debian-package|x-gtar-compressed|x-gzip|x-lzh|x-redhat-package-manager|x-tar|zip)"
        ]
      ],
      "error_on_decline": false
    },
    "non-archives": {
      "use": ":original",
      "robot": "/file/filter",
      "declines": [
        [
          "${file.mime}",
          "regex",
          "application/(rar|x-7z-compressed|x-cab|x-cpio|x-debian-package|x-gtar-compressed|x-gzip|x-lzh|x-redhat-package-manager|x-tar|zip)"
        ]
      ],
      "error_on_decline": false
    },
    "extracted": {
      "use": "archives",
      "robot": "/file/decompress"
    },
    "encoded-ipad": {
      "use": [
        "non-archives",
        "extracted"
      ],
      "robot": "/video/encode",
      "ffmpeg_stack": "v2.2.3",
      "preset": "ipad-high",
      "result": true
    },
    "encoded-webm": {
      "use": [
        "non-archives",
        "extracted"
      ],
      "robot": "/video/encode",
      "ffmpeg_stack": "v2.2.3",
      "preset": "webm",
      "result": true
    },
    "exported": {
      "use": [
        ":original",
        "encoded-ipad",
        "encoded-webm"
      ],
      "robot": "/s3/store",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Only resize larger images when resizing files

{
  "steps": {
    "large-files": {
      "use": ":original",
      "robot": "/file/filter",
      "accepts": [
        [
          "${file.meta.width}",
          ">",
          "2048"
        ],
        [
          "${file.meta.height}",
          ">",
          "2048"
        ]
      ],
      "condition_type": "or"
    },
    "smaller-files": {
      "use": ":original",
      "robot": "/file/filter",
      "accepts": [
        [
          "${file.meta.width}",
          "<=",
          "2048"
        ],
        [
          "${file.meta.height}",
          "<=",
          "2048"
        ]
      ],
      "condition_type": "or"
    },
    "large-resized": {
      "use": "large-files",
      "robot": "/image/resize",
      "resize_strategy": "fit",
      "width": 2048,
      "height": 2048
    },
    "smaller-resized": {
      "use": "smaller-files",
      "robot": "/image/resize",
      "resize_strategy": "fit",
      "width": "${file.meta.width}",
      "height": "${file.meta.height}"
    },
    "optimized": {
      "use": [
        "smaller-resized",
        "large-resized"
      ],
      "robot": "/image/optimize"
    },
    "exported": {
      "use": [
        "optimized",
        ":original"
      ],
      "robot": "/s3/store",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Automatically reject virus-infected files with an error

{
  "steps": {
    "safe": {
      "use": ":original",
      "robot": "/file/virusscan",
      "error_on_decline": true
    },
    "exported": {
      "robot": "/s3/store",
      "use": "safe",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Specify multiple encoding Steps for a single file

{
  "steps": {
    "ipad_video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "ffmpeg_stack": "v2.2.3",
      "preset": "ipad-high",
      "width": 854,
      "height": 480
    },
    "iphone_video": {
      "use": ":original",
      "robot": "/video/encode",
      "ffmpeg_stack": "v2.2.3",
      "result": true,
      "preset": "iphone"
    },
    "thumbnails": {
      "use": ":original",
      "robot": "/video/thumbs"
    },
    "resized_thumbs": {
      "robot": "/image/resize",
      "use": "thumbnails",
      "result": true,
      "width": 130,
      "height": 130
    },
    "exported": {
      "robot": "/s3/store",
      "use": [
        ":original",
        "ipad_video",
        "iphone_video",
        "resized_thumbs"
      ],
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Automatically process multiple file types

{
  "steps": {
    "image_thumbs": {
      "use": ":original",
      "robot": "/image/resize",
      "result": true,
      "format": "png",
      "width": 320,
      "height": 240
    },
    "video_thumbs": {
      "use": ":original",
      "robot": "/video/thumbs",
      "result": true,
      "width": 320,
      "height": 240,
      "resize_strategy": "pad",
      "background": "#000000",
      "count": 4
    },
    "encode_video": {
      "use": ":original",
      "robot": "/video/encode",
      "result": true,
      "preset": "ipad-high",
      "ffmpeg_stack": "v2.2.3",
      "width": 640,
      "height": 480
    },
    "exported": {
      "use": [
        "image_thumbs",
        "video_thumbs",
        "encode_video",
        ":original"
      ],
      "robot": "/s3/store",
      "bucket": "YOUR_S3_BUCKET",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET"
    }
  }
}

Convert any video to animated GIF

{
  "steps": {
    "extracted_thumbs": {
      "use": ":original",
      "robot": "/video/thumbs",
      "result": false,
      "count": 50
    },
    "anigif": {
      "robot": "/video/merge",
      "use": {
        "steps": [
          {
            "name": "extracted_thumbs",
            "as": "image"
          }
        ]
      },
      "result": true,
      "duration": 7.8,
      "framerate": "10",
      "ffmpeg_stack": "v2.2.3",
      "ffmpeg": {
        "f": "gif",
        "pix_fmt": "rgb24"
      },
      "resize_strategy": "pad"
    },
    "exported": {
      "use": [
        ":original",
        "anigif"
      ],
      "robot": "/s3/store",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Encode video for Android, preserving the original quality

{
  "steps": {
    "android-preserve-quality": {
      "use": ":original",
      "robot": "/video/encode",
      "preset": "android",
      "result": "true",
      "ffmpeg_stack": "v2.2.3",
      "width": "${file.meta.width}",
      "height": "${file.meta.height}",
      "ffmpeg": {
        "b:v": "${file.meta.video_bitrate}",
        "maxrate": "${file.meta.video_bitrate}",
        "bufsize": "${file.meta.video_bitrate}",
        "r": "${file.meta.framerate}",
        "ar": "${file.meta.audio_samplerate}",
        "b:a": "${file.meta.audio_bitrate}"
      }
    },
    "exported": {
      "use": [
        ":original",
        "android-preserve-quality"
      ],
      "robot": "/s3/store",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Implement HTTP Live Streaming (HLS)

{
  "steps": {
    "low": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "hls_270p"
    },
    "mid": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "hls_360p"
    },
    "high": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "hls_540p"
    },
    "adaptive": {
      "robot": "/video/adaptive",
      "use": {
        "steps": [
          "low",
          "mid",
          "high"
        ],
        "bundle_steps": true
      },
      "technique": "hls",
      "playlist_name": "my_playlist.m3u8"
    },
    "exported": {
      "robot": "/s3/store",
      "use": "adaptive",
      "path": "hlstest/${file.meta.relative_path}/${file.name}",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Implement MPEG-Dash using Transloadit

{
  "steps": {
    "270p_video": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "dash_270p_video"
    },
    "360p_video": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "dash_360p_video"
    },
    "32k_audio": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "dash_32k_audio"
    },
    "64k_audio": {
      "robot": "/video/encode",
      "use": ":original",
      "ffmpeg_stack": "v2.2.3",
      "preset": "dash_64k_audio"
    },
    "adaptive": {
      "robot": "/video/adaptive",
      "use": {
        "steps": [
          "270p_video",
          "360p_video",
          "32k_audio",
          "64k_audio"
        ],
        "bundle_steps": true
      },
      "technique": "dash",
      "playlist_name": "my_playlist.mpd"
    },
    "exported": {
      "robot": "/s3/store",
      "use": "adaptive",
      "path": "dashtest/${file.meta.relative_path}/${file.name}",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Related blog posts

Over the years we wrote the following posts about Our /s3/store robot on our blog:

Did you know?

You can easily combine Robots to create powerful workflows, unique to your business.
This is the power of Transloadit.