A simple wrapper for cos
Project description
easy_cos
让数据流动变得简单!Make data flow!
pip install easy_cos==0.1.0 --index-url https://pypi.tuna.tsinghua.edu.cn/simple
#
pip install easy_cos==0.1.0 --index-url https://pypi.org/simple #清华等其他镜像源可能同步慢
这个库的开发是包含了大部分常用的 cos 脚本操作,避免许多重复代码。以及让很多新入职的同事能够快速用起来我们的数据。、
准备工作
# 安装 SDK
COS_CONFIG = {
'secret_id': f'{os.environ["COS_SECRET_ID"]}',
'secret_key': f'{os.environ["COS_SECRET_KEY"]}',
'region': f'{os.environ["COS_REGION"]}',
}
场景一(list all files under a cos dir):
from easy_cos import list_all_files_under_cos_dir
list_all_files_under_cos_dir(
cos_dir="cos://bucket_name/prefix",
config=COS_CONFIG,
verbose=True,
return_path_only=True,
)
场景二(check if a cos path exists):
from easy_cos import check_cos_path_exist
check_cos_path_exist(
cos_path="cos://bucket_name/prefix/file.txt",
config=COS_CONFIG,
)
场景三(delete a cos file):
from easy_cos import delete_cos_file
delete_cos_file(
cos_path="cos://bucket_name/prefix/file.txt",
config=COS_CONFIG,
)
场景四(delete a cos dir):
from easy_cos import delete_cos_dir
delete_cos_dir(
cos_dir="cos://bucket_name/prefix",
config=COS_CONFIG,
)
场景五(download a cos file):
from easy_cos import download_cos_file
download_cos_file(
cos_path="cos://bucket_name/prefix/file.txt",
local_file_path="local/path/file.txt",
config=COS_CONFIG,
)
场景六(download a cos dir):
from easy_cos import download_cos_dir
download_cos_dir(
cos_dir="cos://bucket_name/prefix",
local_dir="local/path",
config=COS_CONFIG,
)
场景七(save an image to cos):
from easy_cos import save_img2cos
save_img2cos(
img=Image.open("image.jpg"),
cos_save_path="cos://bucket_name/prefix/image.jpg",
config=COS_CONFIG,
)
场景八(upload a file to cos):
from easy_cos import upload_file2cos
upload_file2cos(
local_file_path="local/path/file.txt",
cos_save_path="cos://bucket_name/prefix/file.txt",
config=COS_CONFIG,
)
场景九(upload a dir to cos):
from easy_cos import upload_dir2cos
upload_dir2cos(
local_upload_dir="local/path",
cos_dir="cos://bucket_name/prefix",
config=COS_CONFIG,
)
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
easy_cos-0.1.2.tar.gz
(9.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easy_cos-0.1.2.tar.gz.
File metadata
- Download URL: easy_cos-0.1.2.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3581622558c1d7a4bcc598e0e6fd873e8924d62528fbe97fca1e5c52b461d8a3
|
|
| MD5 |
6cd033b74f676e9314df2588676220e1
|
|
| BLAKE2b-256 |
420369e1a166002af8ad3ea7ef655e50347848289a04e48ed5735d60a129cf90
|
File details
Details for the file easy_cos-0.1.2-py3-none-any.whl.
File metadata
- Download URL: easy_cos-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0d587951ea6317e17d72f57aa3a829e4331b183a77391bc8694fbc3d9b04886
|
|
| MD5 |
6d17ca464b52d10e24300f178f8ac485
|
|
| BLAKE2b-256 |
ca4ef3621352048a50079bd1a7642186100148b87a7967fc1d6dcecca502b2b2
|