Transfer image files from MongoDB to S3
In MongoDB, this is called GridFS, but s3cmd can only upload files from your operational system filesystem.
You need to make a script to query GridFS, create a temporary file, then use scm3 to upload it.

Read this article describing how to use GridFS on Node.JS: https://mongodb.github.io/node-mongodb-native/api-articles/nodekoarticle2.html

If you want to understand how to make a GridFS to S3 script, see this Perl script: https://github.com/mediaprojects/gridfs-to-s3

And if you have Perl installed, you can just run the script.