Storj uplink CLI: install and basic commands
Install the Storj uplink command-line tool on Linux, list, copy, share and delete objects, and mount a bucket with s3fs.
Storj provides object storage with an S3-compatible gateway. The uplink command-line tool manages access grants, buckets and objects. The examples use placeholder names (bucket-name, folder, example-bucket).
Install on Linux
curl -L https://github.com/storj/storj/releases/latest/download/uplink_linux_amd64.zip -o uplink_linux_amd64.zip
unzip -o uplink_linux_amd64.zip
chmod 755 uplink
sudo mv uplink /usr/local/bin/uplink
Documentation: Set up the uplink CLI and Storj client libraries.
Access grant
uplink import access-grant.key
uplink access list
uplink setup
The first command imports an access grant saved in a file. uplink setup runs the initial configuration.
Basic operations
uplink ls sj://bucket-name/folder/
uplink cp local-file.jpg sj://bucket-name/folder/local-file.jpg
uplink rm sj://bucket-name/folder/local-file.jpg
uplink share --url sj://bucket-name/folder/archive.zip
uplink rb sj://bucket-name --force
uplink rb --force removes a bucket together with its content.
Count objects and size
uplink ls sj://bucket-name/folder | sort -k 2 -k 3 -r | head -n 5
uplink ls sj://bucket-name/folder | awk '{sum += $4} END {print sum}'
bc -l <<< "$(uplink ls sj://bucket-name/folder | awk '{sum += $4} END {print sum}')/1024/1024/1024"
The last command converts the total size from bytes to GiB. The column numbers used by awk depend on the layout of the uplink ls output of your version.
Delete all objects of a prefix in parallel
This command is destructive. To preview the operations, replace rm with echo first.
uplink ls --recursive sj://bucket-name/ | tr -s ' ' | cut -f5- -d' ' | sed 's/ /\ /g' | xargs -n1 -P32 -d'\n' -iNAME uplink --client.dial-timeout 10s --client.request-timeout 10s rm sj://bucket-name/NAME
-P32 runs 32 deletions in parallel.
Mount a bucket with s3fs
The Storj gateway is S3-compatible, so s3fs can mount a bucket. Store the credentials in a password file:
echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > /etc/passwd-s3fs
chmod 600 /etc/passwd-s3fs
Mount the bucket manually:
s3fs example-bucket /mnt/storj -o url=https://gateway.storjshare.io
Mount at boot with /etc/fstab:
s3fs#example-bucket /mnt/storj fuse _netdev,allow_other,url=https://gateway.storjshare.io,umask=000,uid=33,gid=33,use_cache=/root/cache 0 0
Notes
- Access keys, secrets, satellite addresses, passphrases and bucket names from the source were replaced with placeholders.
- The Duplicati and Windows test sections of the source were left out.
- The
chmod 600on the password file is a recommendation added here; it is not in the source. - The fstab line of the source ended with four zeros; it is shown with the two fields that fstab expects.