fiuai-s3 0.4.2__tar.gz → 0.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fiuai-s3 might be problematic. Click here for more details.
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/PKG-INFO +1 -1
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/pyproject.toml +1 -1
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/src/fiuai_s3/alicloud/alicloud_storage.py +27 -1
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/src/fiuai_s3/minio/minio_storage.py +4 -1
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/src/fiuai_s3/object_storage.py +4 -1
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/.gitignore +0 -0
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/LICENSE +0 -0
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/README.md +0 -0
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/src/fiuai_s3/__init__.py +0 -0
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/src/fiuai_s3/alicloud/__init__.py +0 -0
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/src/fiuai_s3/minio/__init__.py +0 -0
- {fiuai_s3-0.4.2 → fiuai_s3-0.4.3}/src/fiuai_s3/type.py +0 -0
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import os
|
|
9
9
|
import logging
|
|
10
|
-
from typing import List, Optional
|
|
10
|
+
from typing import List, Optional, Dict
|
|
11
11
|
import oss2
|
|
12
12
|
from ..object_storage import ObjectStorage, StorageConfig
|
|
13
13
|
from oss2.headers import OSS_OBJECT_TAGGING
|
|
@@ -37,6 +37,32 @@ class AliCloudStorage(ObjectStorage):
|
|
|
37
37
|
bucket_name=config.bucket_name
|
|
38
38
|
)
|
|
39
39
|
|
|
40
|
+
def upload_temp_file(self, object_key: str, data: bytes, tmppath: str = None) -> bool:
|
|
41
|
+
"""上传临时文件到阿里云OSS
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
object_key: 对象存储中的key
|
|
45
|
+
data: 文件数据
|
|
46
|
+
tmppath: 临时文件路径, 如果为空,则使用默认临时目录
|
|
47
|
+
Returns:
|
|
48
|
+
bool: 是否上传成功
|
|
49
|
+
"""
|
|
50
|
+
_path = f"{self.config.temp_dir}/{object_key}" if not tmppath else f"{tmppath.rstrip('/')}/{object_key}"
|
|
51
|
+
return self.upload_file(_path, data)
|
|
52
|
+
|
|
53
|
+
def download_temp_file(self, object_key: str, tmppath: str = None) -> bytes:
|
|
54
|
+
"""从阿里云OSS下载临时文件
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
object_key: 对象存储中的key
|
|
58
|
+
tmppath: 临时文件路径, 如果为空,则使用默认临时目录
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
bytes: 文件内容,失败时返回None
|
|
62
|
+
"""
|
|
63
|
+
_path = f"{self.config.temp_dir}/{object_key}" if not tmppath else f"{tmppath.rstrip('/')}/{object_key}"
|
|
64
|
+
return self.download_file(_path)
|
|
65
|
+
|
|
40
66
|
def upload_file(self, object_key: str, data: bytes) -> bool:
|
|
41
67
|
"""上传文件到阿里云OSS
|
|
42
68
|
|
|
@@ -81,12 +81,15 @@ class MinioStorage(ObjectStorage):
|
|
|
81
81
|
_path = f"{self.config.temp_dir}/{object_key}" if not tmppath else f"{tmppath.rstrip('/')}/{object_key}"
|
|
82
82
|
return self.upload_file(_path, data)
|
|
83
83
|
|
|
84
|
-
def download_temp_file(self, object_key: str, tmppath: str = None) ->
|
|
84
|
+
def download_temp_file(self, object_key: str, tmppath: str = None) -> bytes:
|
|
85
85
|
"""下载临时文件
|
|
86
86
|
|
|
87
87
|
Args:
|
|
88
88
|
object_key: 对象存储中的key
|
|
89
89
|
tmppath: 临时文件路径, 如果为空,则使用默认临时目录
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
bytes: 文件内容,失败时返回None
|
|
90
93
|
"""
|
|
91
94
|
_path = f"{self.config.temp_dir}/{object_key}" if not tmppath else f"{tmppath.rstrip('/')}/{object_key}"
|
|
92
95
|
return self.download_file(_path)
|
|
@@ -58,12 +58,15 @@ class ObjectStorage(ABC):
|
|
|
58
58
|
pass
|
|
59
59
|
|
|
60
60
|
@abstractmethod
|
|
61
|
-
def download_temp_file(self, object_key: str, tmppath: str = None) ->
|
|
61
|
+
def download_temp_file(self, object_key: str, tmppath: str = None) -> bytes:
|
|
62
62
|
"""下载临时文件
|
|
63
63
|
|
|
64
64
|
Args:
|
|
65
65
|
object_key: 对象存储中的key
|
|
66
66
|
tmppath: 临时文件路径, 如果为空,则使用默认临时目录
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
bytes: 文件内容,失败时返回None
|
|
67
70
|
"""
|
|
68
71
|
pass
|
|
69
72
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|