Last updated: May 29, 2024

<span aria-hidden="true" id="efficient-dropbox-to-sftp-file-transfer-with-optimization"></span>

# Efficient Dropbox to SFTP file transfer with optimization

![Tyler McAllister](/assets/images/teammates/tyler.png?dpl=dpl_G4M3RiQtx3dAhoWEFaDoowGHFzob)

**Tyler McAllister**

Technical Writer · Trondheim, Norway · Show bio

When we last left off in the Re-loadit series, I [covered an example](/blog/2018/12/dropbox-store.md)using the [/dropbox/store](/docs/robots/dropbox-store.md) Robot. This time, I want to import files from my personal Dropbox. So, continuing with the Dropbox theme, it's the[/dropbox/import](/docs/robots/dropbox-import.md) Robot's time to shine!

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

## The /dropbox/import Robot

In contrast to the [/dropbox/store](/docs/robots/dropbox-store.md) Robot, the[/dropbox/import](/docs/robots/dropbox-import.md) Robot will allow you to import directories directly from your Dropbox storage to be passed onto other steps within anAssembly.

![/dropbox/import Robot](/_next/static/immutable/media/opengraph-image.3odcx__j-739y.png)

Images are some of the most popular file types stored on Dropbox. From a personal point of view, apart from storing my invoices, I mostly use my Dropbox for storing various images to share them with friends and family. That said, Dropbox as a service isn't always ideal. Personally, I feel more comfortable storing some of my files on my own SFTP server. Especially since I'm starting to run out of space on Dropbox and my student budget doesn't allow for a Dropbox subscription 😉

So, for this example, I will be introducing an Assembly that allows me to move the images from one of my Dropbox folders to my SFTP server - running on my very own Raspberry Pi. As an extra step, I also want to reduce the file size of these images since my Raspberry Pi's SD card is only 8GB.

For the curious, the Dropbox folder containing the images I want looks like this. There's a mix of media files in here, so I'll also need a way to filter out the unwanted files.

![My Dropbox media folder](/_next/static/immutable/media/2019-01-07-dropbox-import-file-media-folder.2i9xqy3rpk74a.png)

Let's see how exactly to build such an Assembly. Feel free to follow along!

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

## Creating the Assembly

For this task I'll be making use of four Robots:

* The [/dropbox/import](/docs/robots/dropbox-import.md) Robot to get what I need from my **media/** folder;
* The [/file/filter](/docs/robots/file-compress.md) Robot to ensure I'm filtering out any undesired file types;
* The [/image/optimize](/docs/robots/image-optimize.md) Robot to reduce the file size of the images being imported; and
* Finally, the [/sftp/store](/docs/robots/sftp-store.md) Robot will let me store everything on my own SFTP server.

That's a decent number of Robots doing some fairly complex tasks. Check out theTemplate I created below:

```json
{
  "steps": {
    "imported": {
      "robot": "/dropbox/import",
      "result": true,
      "credentials": "my_dropbox_credentials",
      "path": "media/"
    },
    "filtered_images": {
      "use": ["imported"],
      "robot": "/file/filter",
      "result": true,
      "accepts": [["${file.mime}", "regex", "image/(jpeg|png|svg|tiff)"]]
    },
    "optimize": {
      "use": ["filtered_images"],
      "robot": "/image/optimize",
      "priority": "compression-ratio",
      "progressive": false,
      "preserve_meta_data": false,
      "fix_breaking_images": true
    },
    "exported": {
      "use": ["optimize"],
      "robot": "/sftp/store",
      "credentials": "my_sftp_credentials",
      "path": "/home/pi/sftp/images/${file.original_basename}.${file.ext}"
    }
  }
}

```

As usual, I prefer to keep the credentials for both my Dropbox access token and SFTP details (such as hostname) safe in the [Template Credentials](/c/template-credentials/) section of Transloadit. From the initial Step, the [/dropbox/import](/docs/robots/dropbox-import.md) Robot will import all files specified by the `path` parameter, in this case my \*\*media/\*\*folder. This folder contains a number of images, but also some miscellaneous files, like documents and mp3s.

Not all of those files are relevant, so I use the [/file/filter](/docs/robots/dropbox-import.md) Robot to filter out anything that isn't a *jpeg*, *png*, *svg* or *tiff*. The impressive[/image/optimize](/docs/robots/image-optimize.md) Robot then takes these images and helps reduce their file size while maintaining their quality. Finally, I export the results to my SFTP server - letting them live comfortably on my Raspberry Pi.

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

## The results

After a quick check on my Pi's filesystem, the results are looking good! All of the images that were present in my Dropbox **media/** folder are now also present on my SFTP server. And as a nice bonus, I've managed to whittle down some of the file sizes too! 😍

![Results on Pi](/_next/static/immutable/media/2019-01-07-dropbox-import-pi-files.38jpxpykbk-26.png)

Stay tuned for the next installment in our Re-loadit series!

[#file-importing-service](/blog/tags/file-importing-service.md)[#dropbox-import-robot](/blog/tags/dropbox-import-robot.md)[#integrations](/blog/tags/integrations.md)[#re-loadit](/blog/tags/re-loadit.md)[#dropbox-store-robot](/blog/tags/dropbox-store-robot.md)[#sftp-store-robot](/blog/tags/sftp-store-robot.md)[#file-filter-robot](/blog/tags/file-filter-robot.md)[#image-optimize-robot](/blog/tags/image-optimize-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
