Sharing files with Openstack and swift

Say you have a file be it a pdf, word document or even a large iso. You can use Openstack to temporarily share this file with others.

This assumes you are authenticated with Openstack API already.(Openstack Client Access)

Make sure you have a tempurl key generated and attached to your account (this only has to be done once and not every time you want to share a file)

#generate a key with uuidgen

$ uuidgen
$ 6b4139c0-3eda-4e3f-8bcf-97b0f19014b9
$ swift post -m 'Temp-URL-KEY:6b4139c0-3eda-4e3f-8bcf-97b0f19014b9'

The rest needs to be done each time you want to share a file or renew a url:
#First check account to collect data.

$swift stat

#From the output you will need the “Account” and “Meta Temp-Url-Key”
Account: KEY_6e9ed9c765b24951a7ca132a9acc87e4
Containers: 2
Objects: 1
Bytes: 4497342464
Containers in policy "standard-replica": 2
Objects in policy "standard-replica": 1
Bytes in policy "standard-replica": 4497342464
Meta Temp-Url-Key: 6c5d1c06-3f72-4d35-a806-3a90fbcdc1e5
Accept-Ranges: bytes
X-Trans-Id: tx0fdfd888549d41828a34e-005d691977
X-Account-Project-Domain-Id: default
X-Openstack-Request-Id: tx0fdfd888549d41828a34e-005d691977
X-Timestamp: 1564430023.61286
Content-Type: application/json; charset=utf-8

#Create a container or folder to place the file in:

$swift post iso

#Upload your file or object to the container

$swift upload iso /home/user/rhel7.iso

#Next, create a tempurl (filling in the brackets with the information we retrieved from the "swift stat" command above).

$swift tempurl 3600 /v1/{Account}/iso/rhel7.iso {Meta Temp-Url-Key}

/v1/KEY_6e9ed9c765b24951a7ca132a9acc87e4/iso/rhel7.iso?temp_url_sig=da4d84647bbe41f0a7fc2e0b723d5a8cc190999d&temp_url_expires=1567172915

#The resulting output should be appended to the swift endpoint. In this instance it would look something like:

https://swift.storm.gatech.edu/v1/KEY_6e9ed9c765b24951a7ca132a9acc87e4/iso/rhel7.iso?temp_url_sig=da4d84647bbe41f0a7fc2e0b723d5a8cc190999d&temp_url_expires=1567172915

Note: The url you generate will only be available for the amount of time (in seconds) you provided in the $swift tempurl command above. After which you'll need to generate another url.