When uploading files via SFTP, the modified date of the original file gets replaced by the current time. In case you need this information, SFTP Gateway makes it available on the S3 object metadata.

First, upload a file via the command line:

sftp -i robtest.key robtest@<public ip>
sftp> ls
local uploads 
sftp> cd uploads 
sftp> put -p test.txt 

Note the use of the -p flag in your put command. This preserves the original modified date.

SFTP Gateway uploads this file to S3, and the modified date gets overwritten by the current time. From the EC2 instance, run the following command:

aws s3 ls s3://<bucket name>/robtest/uploads/test.txt

And this gives the current time:

2018-07-09 17:45:58 21739 test.txt

However, you can access the original modified date from the S3 object’s metadata.

aws s3api head-object --bucket <bucket name> --key robtest/uploads/test.txt --query 'Metadata.mtime' --output text

This gives the following output:

2017-09-24 19:53:52.000000000 +0000