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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fiuai-s3
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: 一个支持阿里云OSS和MinIO的对象存储抽象包
5
5
  Project-URL: Homepage, https://github.com/fiuai-sz/fiuai-s3
6
6
  Project-URL: Repository, https://github.com/fiuai-sz/fiuai-s3.git
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "fiuai-s3"
7
- version = "0.4.2"
7
+ version = "0.4.3"
8
8
  description = "一个支持阿里云OSS和MinIO的对象存储抽象包"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -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) -> bool:
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) -> bool:
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