Home Upload to S3 from Linux file manager
Post
Cancel

Upload to S3 from Linux file manager

One day while traversing through the directories and realizing that folders/files that are not accessed on a day-to-day basis are taking up space on the NVMe SSD and decides that they are uploaded to S3 compatible cold object storage so that it is safe and secure and can be accessed whenever and wherever but do not waste the puny SSD space. 😃

Scaleway1 has some really nice storage options:

You get 75GB free storage and external outgoing transfer on both Object Storage and C14 Cold Storage every month! For Object Storage’s Standard Class, the price charged after 75GB is €0.01/GB per month per volume stored, and €0.01/GB per volume transferred. In addition, transfer to and from other Scaleway products in the same region is completely free! You also don’t have any fees per API or console request.

Okay, let’s do it!

1
$ wget https://dl.minio.io/client/mc/release/linux-amd64/mc -P /usr/bin/ && chmod +x /usr/bin/mc
  • Configure minio
1
$ vim ~/.mc/config.json

append the folloing to the config.json file:

1
2
3
4
5
6
7
“s3”: {
“url”: “https://s3.fr-par.scw.cloud“,
“accessKey”: “key-here”,
“secretKey”: “xxxx-x-xx-x-x-x-x-x — x-x-”,
“api”: “S3v4”,
“path”: “auto”
}

Tadaa!!!

Upload a file folder directly from the command line as follows:

1
$ mc cp — recursive ‘directory with spaces/’ s3/bucket/

Or, why not integrate it into the Linux Mint’s context menu
?!


like this:

Window shadow

Let us check the Linux Mint Nemo source to find out how.

1
2
3
4
5
6
7
8
9
[Nemo Action]
Active=true
Name=Upload to S3
Comment=Upload to Object Storage
Exec=/usr/bin/python3 /home/<username>/s3.py %F
Selection=any
Terminal=true
Extensions=any;
EscapeSpaces=true

Create the target s3.py file:

1
2
3
4
5
6
7
8
9
10
import os
import sys
if __name_ == ' _main__':
    for index, arg in enumerate(sys.argv):
        if index != 0:
            print (arg)
            if os. path.isdir (arg):
                os.system (f'mc cp --recursive "{arg}" s3/bucket/HomePC')
            else:
                os.system (f'mc cp "{arg}" s3/bucket/HomePC')

Voila!

This post is licensed under CC BY 4.0 by the author.