Swift/S3 Typescript client
Only tested with Infomaniak Public cloud (OpenStack)
Migrate from a folder
See python code below
import os
import requests
directory = '.'
files = os.listdir(directory)
token = 'xxx'
swiftUrl = "https://s3.pub1.infomaniak.cloud/object/v1/AUTH_xxx"
containerName = "xxx"
for i, file_path in enumerate(files):
url = swiftUrl + '/' + containerName + '/' + file_path
headers = { "X-Auth-Token": token,
'Content-Type': 'text/plain',
'Content-Length': str(os.path.getsize(file_path))
}
file = open(file_path, 'rb')
file_data = file.read()
#files = {'file': (file_path, file_data)}
response = requests.put(url, headers=headers, data=file_data)
print(file_path, os.path.basename(file_path), url, response)