https://github.com/nexys-system/swifts3-client
Typescript Swift/S3 client
https://github.com/nexys-system/swifts3-client
s3 swift typescript
Last synced: 3 months ago
JSON representation
Typescript Swift/S3 client
- Host: GitHub
- URL: https://github.com/nexys-system/swifts3-client
- Owner: nexys-system
- Created: 2023-04-01T12:15:14.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-02T01:10:51.000Z (almost 2 years ago)
- Last Synced: 2025-02-27T17:58:57.214Z (4 months ago)
- Topics: s3, swift, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@nexys/swifts3-client
- Size: 227 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Swift/S3 Typescript client
[](https://www.npmjs.com/package/@nexys/swifts3-client)
[](https://github.com/nexys-system/swifts3-client/actions/workflows/test.yml)
[](https://github.com/nexys-system/swifts3-client/actions/workflows/publish.yml)
Only tested with [Infomaniak Public cloud (OpenStack)](https://www.infomaniak.com/en/hosting/public-cloud)
## Migrate from a folder
See python code below
```
import os
import requestsdirectory = '.'
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)
```