A package for handling various storage options.
Project description
dobby-storage
https://github.com/Ting-Yu/dobby-storage.git
S3 Information
- CUSTOM_AWS_ACCESS_KEY_ID
- CUSTOM_AWS_SECRET_ACCESS_KEY
- CUSTOM_AWS_DEFAULT_REGION
- CUSTOM_AWS_BUCKET
FTP Information
- CUSTOM_FTP_SERVER
- CUSTOM_FTP_USER
- CUSTOM_FTP_PASSWORD
Google Drive Information
- CUSTOM_GOOGLE_DRIVE_AUTH_PATH
Install Module
pip install dobby-storage
Unit Test
pytest
Usage
from dobby_storage.storage import FileStorage
# if you want to use storage.json, please refer to dobby_storage/storage.json
# but I still recommend you to set it up in os system environment, the setting is as above, S3 Information, FTP Information, Google Drive Information
file_storage = FileStorage('storage.json')
# 1. Local storage
result = file_storage.save('upload_test.txt', 'destination.txt')
print(f"Local storage File {result}.")
# 2. Using S3 storage with upload_file
file_storage.use_disk('s3')
result = file_storage.save('upload_test.txt', 'destination.txt', bucket_name='fribooker')
print(f"S3 storage with upload_file File {result}.")
# 3. Using S3 storage with upload_fileobj
result = file_storage.save('upload_test.txt', 'destination.txt', bucket_name='fribooker', use_fileobj=True)
print(f"S3 storage with upload_fileobj File {result}.")
# 4. Using FTP storage
file_storage.use_disk('ftp')
result = file_storage.save('upload_test.txt', 'destination.txt')
print(f"FTP storage File {result}.")
# 5. Using Google Drive storage
file_storage.use_disk('google_drive')
result = file_storage.save('upload_test.txt')
print(f"Google Drive storage File {result}.")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dobby_storage-1.0.2.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file dobby_storage-1.0.2.tar.gz
.
File metadata
- Download URL: dobby_storage-1.0.2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
c39160acf1286106dd6b68e207bf0e1da52f714073626f6c271be5c88167326f
|
|
MD5 |
7b2bb949fa6726ffd5be85d245c5df95
|
|
BLAKE2b-256 |
a4bd25d4d74e92a10ab0a5efe4d5793e1a2b578a312829fab20693e11ad63f80
|
File details
Details for the file dobby_storage-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: dobby_storage-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
a94adf5a41dd420937e88dfec0caf7fae5662c7c837a7c1bb0a44cdb23ba64a6
|
|
MD5 |
a75749e172f24d40369eb7d515eba9de
|
|
BLAKE2b-256 |
22ea5eb1d8b06ebfc16b9872b3c2980047b703c22b76d3b4e30425145b45f151
|