How to Download Newly Added Files from an AWS S3 Folder

Using our MFT server, you can monitor AWS S3 folders and automatically download each file added there. Check out our step-by-step tutorial online at JSCAPE.
  1. Blog

Organizations with hybrid infrastructures consisting of cloud-based and on-premise solutions will usually need the ability to conduct automated data transfers between these two domains. JSCAPE MFT Server's extensive cloud integration features can be a big help in meeting this requirement. In this particular example, we're going to demonstrate how easy it is to set up MFT Server to monitor a folder in an Amazon S3 bucket and automatically download each file added there.

amazon s3 download

Watch the video

Would you prefer to watch a video version of this tutorial instead? You can play the video below. Otherwise, just skip it if you wish to continue reading.

I'll be assuming you already have an Amazon S3 trading partner object in your JSCAPE MFT Server instance. If you don't have one yet, I suggest you read the post 'How To Connect and Upload Files To an Amazon S3 Trading Partner' or watch the video in that post. In this example, our S3 trading partner is named 'tp-s3'.

s3 tading partner

Once you've got your Amazon S3 trading partner, the next step is to create a Directory Monitor that would monitor a AWS S3 folder on that trading partner for newly added files. To do that, just go to the Directory Monitors module and click the Add button.

adding new directory monitor for s3

Give the directory monitor a name, say for example, 'dm-s3'.

After that, tick the Use trading partner checkbox and select the name of your existing S3 trading partner from the drop down list. In our case, that would be 'tp-s3'.

Next, go the Directory field and enter the path to the AWS S3 folder you want to monitor. So, for example, I have an S3 bucket named 'jscapejohn' and a folder named 'folder1' inside that bucket, and that's the folder I want to monitor, so I enter:

jscapejohn/folder1

If you just need to monitor this particular folder and none of the subfolders underneath it, just untick the Monitor recursively checkbox.

In the Settings panel, you'll see a checkbox labeled Monitor interval. That's the regular period of time in seconds that MFT Server will go in and check to see if a new file has been added to this monitored directory. You may want to adjust that to suit your specific requirements.

add directory monitor for s3 folder

Lastly, because we just want to monitor this directory for newly added files (and not for file changes, file deletions, and aged files), we just leave the Monitor file add checkbox ticked.

As soon as you're done, click the OK button.

monitor file add s3

In the Directory Monitors tab, you'll see your newly created directory monitor.

s3 directory monitor

Now that we have directory monitor for monitoring a folder in our S3 bucket, the next thing we need to do is create a trigger that would automatically download each newly added file that's detected by the directory monitor.

Go to the Triggers module and click the Add button.

add new trigger

Give the trigger a name, say, 'download new s3 files', give it a suitable description (something that will give other server admins an idea what this particular trigger does), and select Directory Monitor File Added from the Event type drop-down list.

Once you're done, click Next.

directory monitor file added trigger

In the Trigger Conditions dialog, one of the things you'll want to specify is the name of the directory monitor. This is important because, in a production MFT Server instance, there's going to be a really good chance you'll have multiple directory monitors running simultaneously. You don't want this trigger responding to every single Directory Monitor File Added event thrown out there.

To specify a monitor name, just click the Variables button and select the MonitorName variable (or you can enter that directly in the expression box) and then enter an expression similar to the one you see below:

MonitorName = "dm-s3"

Click Next to proceed.

trigger condition for s3 monitor

In the succeeding screen, click the Add button and select Trading Partner File Download from the drop-down list. Click OK to proceed.

add action trading partner file download

Once you're inside the trigger action parameters dialog, expand the Partner drop-down list and select your S3 trading partner.

In the Remote File field, enter the %File% variable (or click the Add Variable button and select that variable from the list). Each time this trigger will fire, which will happen each time a file is added to the monitored directory, the path of that file will be entered into the %File% variable. Thus, MFT Server will know from that variable which file to download.

To specify where the file will be stored locally after download, enter the path of the local destination directory and append to that the %Name% variable. This variable simply contains the filename of the downloaded file.

Once you're done, click the OK button.

trading partner file download trigger action s3

newly added trigger download new s3 files

That's it. Now you know how to configure JSCAPE MFT Server to monitor an Amazon S3 bucket folder and download each newly added file.

Try this yourself

Would you like to try this yourself? Download the FREE, fully-functional Starter Edition of JSCAPE MFT Server now.

Download JSCAPE MFT Server Trial