Last updated: May 29, 2024

<span aria-hidden="true" id="introducing-recursive-imports-for-s3-in-transloadit"></span>

# Introducing recursive imports for S3 in Transloadit

![Samuel Ogundipe](/assets/images/teammates/samuel.png?dpl=dpl_57Yv8CaL8TB1QConNpNYtbZm6CfA)

**Samuel Ogundipe**

Technical Writer · Lagos, Nigeria · Show bio

[](https://github.com/samuelayo)

We are excited to show you a new addition to our [/s3/import](/docs/robots/s3-import.md) Robot. Until now, we didn't offer a way to recursively import files from your Amazon S3 buckets to use in Transloadit. Usually, you would need to specify each folder in an Assembly Step — and that can be a lot of work.

At Transloadit, we are always on the lookout for improvements that could make your work easier for you. With recursive imports for S3, it will be much more convenient to import deeply nested folders — or even an entire S3 bucket at once!

![A polygonal blue background with the S3 bucket logo in front.](/_next/static/immutable/media/opengraph-image.2wn0wkx0fn6x7.jpg)

<span aria-hidden="true" id="how-does-it-work"></span>

## How does it work?

You can supply a `path` parameter to the Robot, just like before. With `recursive: false`(set to false by default, to not break BC) only those files directly in the folder represented by that path will be imported. No other files contained in subfolders in that path will be included. With `recursive: true`, those files would be imported as well.

And if you supply `path: '/'`, `'recursive': true`, you can now import an entire S3 bucket. Amazing, isn't it?

> By default, the Robot imports a thousand files per invocation. However, there is support for pagination with the `page_number` and `files_per_page` parameters. If you are importing a large chunk of files and use the Robot with pagination, you should make sure that no files are added to the imported path in the meantime. Otherwise, some files can be omitted by the pagination.

<span aria-hidden="true" id="the-template"></span>

## The Template

```json
{
  "steps": {
    "imported": {
      "robot": "/s3/import",
      "result": true,
      "credentials": "s3_cred",
      "path": "/",
      "recursive": true
    },
    "resized": {
      "use": ["imported"],
      "robot": "/image/resize",
      "result": true,
      "height": 130,
      "imagemagick_stack": "v2.0.3",
      "width": 130,
      "zoom": false
    },
    "exported": {
      "use": ["imported", "resized"],
      "robot": "/s3/store",
      "credentials": "s3_cred",
      "path": "${file.original_path}-resized@130/${file.basename}.${file.ext}"
    }
  }
}

```

The Assembly Instructions above show a typical instruction to import files and resize them using the [/s3/import](/docs/robots/s3-import.md) Robot. Note the changes to two key parameters that differentiate these Instructions for an incursive import fromInstructions for a normal import:

* The presence of `"recursive": true`.
* The `path` parameter passed is the root of the S3 bucket.

When finished, all imported files will appear in the Assembly result JSON.

<span aria-hidden="true" id="pagination-support"></span>

## Pagination support

As said, the [/s3/import](/docs/robots/s3-import.md) Robot will process a thousand files at once. But what if you don't need to import those first thousand files, or maybe the tenth batch of a thousand files? To help with that, we have put together support for pagination. You can now also direct the Robot to the exact page it should start importing from. Take a look at the Assembly Instructions below:

```json
{
  "steps": {
    "imported": {
      "robot": "/s3/import",
      "result": true,
      "credentials": "s3_cred",
      "path": "/",
      "recursive": true,
      "page_number": 10,
      "files_per_page": 500
    },
    "resized": {
      "use": ["imported"],
      "robot": "/image/resize",
      "result": true,
      "height": 130,
      "imagemagick_stack": "v2.0.3",
      "width": 130,
      "zoom": false
    },
    "exported": {
      "use": ["imported", "resized"],
      "robot": "/s3/store",
      "credentials": "s3_cred",
      "path": "${file.original_path}-resized@130/${file.basename}.${file.ext}"
    }
  }
}

```

As you can see, we have told the Robot to start from the tenth page and recursively import five hundred files per page.

There are a couple of things to take special note of here:

* if you supply a page number that is out of index, the Robot will return no results.
* if you supply a `files_per_page` parameter that is greater than 1000, it will generate a validation error.
* if you use recursive imorts, all files will be imported in alphabetical order.

That's it for us again. Happy importing! And if you have questions, comments or concerns, do[let us know](mailto:support@transloadit.com).

[#file-importing-service](/blog/tags/file-importing-service.md)[#s3-import-robot](/blog/tags/s3-import-robot.md)

### 👩‍💻 Join 20k+ developers

Sign up for our [monthly newsletter](/newsletters.md) to receive direct links to 3 exclusive tech — and 2 product updates. No less, no more.

Your email:

Get access

## File uploading and encoding. Made simple.

Transloadit streamlines file handling for developers, trusted by brands like Coursera and The New York Times. We’re known for a reliable API, top-notch support, and a strong commitment to open source, with projects like [Uppy⁠](https://uppy.io) and [Tus⁠](https://tus.io) setting standards in file processing.

[Sign up](/c/)[Book a Demo](https://survey.typeform.com/to/kRg47Xi5)

No credit card needed

Cancel anytime
