tosnativeclient 1.0.0__tar.gz → 1.0.1__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 tosnativeclient might be problematic. Click here for more details.
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/Cargo.lock +3 -1
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/Cargo.toml +2 -2
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/PKG-INFO +2 -1
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/pyproject.toml +1 -0
- tosnativeclient-1.0.1/python/tosnativeclient/__init__.py +21 -0
- tosnativeclient-1.0.1/python/tosnativeclient/tosnativeclient.pyi +211 -0
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/src/lib.rs +16 -0
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/src/list_stream.rs +3 -3
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/src/read_stream.rs +2 -2
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/src/tos_client.rs +4 -4
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/src/tos_error.rs +6 -1
- tosnativeclient-1.0.1/src/tos_raw_client.rs +436 -0
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/src/write_stream.rs +3 -3
- tosnativeclient-1.0.0/python/tosnativeclient/__init__.py +0 -4
- tosnativeclient-1.0.0/python/tosnativeclient/tosnativeclient.pyi +0 -91
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/.github/workflows/CI.yml +0 -0
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/.gitignore +0 -0
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/build.sh +0 -0
- {tosnativeclient-1.0.0 → tosnativeclient-1.0.1}/src/tos_model.rs +0 -0
|
@@ -1505,7 +1505,7 @@ dependencies = [
|
|
|
1505
1505
|
|
|
1506
1506
|
[[package]]
|
|
1507
1507
|
name = "tosnativeclient"
|
|
1508
|
-
version = "1.0.
|
|
1508
|
+
version = "1.0.1"
|
|
1509
1509
|
dependencies = [
|
|
1510
1510
|
"arc-swap",
|
|
1511
1511
|
"async-channel",
|
|
@@ -1704,6 +1704,8 @@ dependencies = [
|
|
|
1704
1704
|
"serde",
|
|
1705
1705
|
"serde_json",
|
|
1706
1706
|
"sha2",
|
|
1707
|
+
"tokio",
|
|
1708
|
+
"tokio-util",
|
|
1707
1709
|
"tracing",
|
|
1708
1710
|
"tracing-appender",
|
|
1709
1711
|
"tracing-subscriber",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "tosnativeclient"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.1"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
publish = false
|
|
6
6
|
authors = ["xiangshijian"]
|
|
@@ -15,7 +15,7 @@ crate-type = ["cdylib"]
|
|
|
15
15
|
[dependencies]
|
|
16
16
|
arc-swap = "1.7.1"
|
|
17
17
|
pyo3 = { version = "0.25.0", features = ["extension-module"] }
|
|
18
|
-
ve-tos-rust-sdk = "2.3.0"
|
|
18
|
+
ve-tos-rust-sdk = { version = "2.3.0", features = ["async-file"] }
|
|
19
19
|
tracing-appender = "0.2.3"
|
|
20
20
|
bytes = "1.10.1"
|
|
21
21
|
tokio = { version = "1.36.0", features = ["rt-multi-thread"] }
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tosnativeclient
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
7
8
|
Summary: python native client for tos
|
|
8
9
|
Author: xiangshijian
|
|
9
10
|
License: Apache-2.0
|
|
@@ -10,6 +10,7 @@ classifiers = [
|
|
|
10
10
|
"Programming Language :: Rust",
|
|
11
11
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
12
12
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
13
|
+
"License :: OSI Approved :: Apache Software License",
|
|
13
14
|
]
|
|
14
15
|
dynamic = ["version"]
|
|
15
16
|
[tool.maturin]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from .tosnativeclient import TosClient, ListStream, ListObjectsResult, TosObject, TosError, TosException, TosRawClient, \
|
|
2
|
+
HeadObjectInput, HeadObjectOutput, GetObjectOutput, DeleteObjectInput, DeleteObjectOutput, GetObjectInput, \
|
|
3
|
+
PutObjectFromBufferInput, PutObjectFromFileInput, PutObjectOutput
|
|
4
|
+
|
|
5
|
+
__all__ = ['TosClient',
|
|
6
|
+
'ListStream',
|
|
7
|
+
'ListObjectsResult',
|
|
8
|
+
'TosObject',
|
|
9
|
+
'TosError',
|
|
10
|
+
'TosException',
|
|
11
|
+
'TosRawClient',
|
|
12
|
+
'HeadObjectInput',
|
|
13
|
+
'HeadObjectOutput',
|
|
14
|
+
'DeleteObjectInput',
|
|
15
|
+
'DeleteObjectOutput',
|
|
16
|
+
'GetObjectInput',
|
|
17
|
+
'GetObjectOutput',
|
|
18
|
+
'PutObjectFromBufferInput',
|
|
19
|
+
'PutObjectFromFileInput',
|
|
20
|
+
'PutObjectOutput'
|
|
21
|
+
]
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
from typing import List, Dict
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TosClient(object):
|
|
7
|
+
region: str
|
|
8
|
+
endpoint: str
|
|
9
|
+
ak: str
|
|
10
|
+
sk: str
|
|
11
|
+
part_size: int
|
|
12
|
+
max_retry_count: int
|
|
13
|
+
max_prefetch_tasks: int
|
|
14
|
+
|
|
15
|
+
def __init__(self, region: str, endpoint: str, ak: str = '', sk: str = '', part_size: int = 8388608,
|
|
16
|
+
max_retry_count: int = 3, max_prefetch_tasks: int = 3, directives: str = '', directory: str = '',
|
|
17
|
+
file_name_prefix: str = '', shared_prefetch_tasks: int = 20):
|
|
18
|
+
...
|
|
19
|
+
|
|
20
|
+
def list_objects(self, bucket: str, prefix: str = '', max_keys: int = 1000, delimiter: str = '') -> ListStream:
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
def head_object(self, bucket: str, key: str) -> TosObject:
|
|
24
|
+
...
|
|
25
|
+
|
|
26
|
+
def get_object(self, bucket: str, key: str, etag: str, size: int) -> ReadStream:
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
def put_object(self, bucket: str, key: str, storage_class: str = '') -> WriteStream:
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ListStream(object):
|
|
34
|
+
bucket: str
|
|
35
|
+
prefix: str
|
|
36
|
+
delimiter: str
|
|
37
|
+
max_keys: int
|
|
38
|
+
|
|
39
|
+
def __iter__(self) -> ListStream: ...
|
|
40
|
+
|
|
41
|
+
def __next__(self) -> ListObjectsResult: ...
|
|
42
|
+
|
|
43
|
+
def close(self) -> None: ...
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ListObjectsResult(object):
|
|
47
|
+
contents: List[TosObject]
|
|
48
|
+
common_prefixes: List[str]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class TosObject(object):
|
|
52
|
+
bucket: str
|
|
53
|
+
key: str
|
|
54
|
+
size: int
|
|
55
|
+
etag: str
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class ReadStream(object):
|
|
59
|
+
bucket: str
|
|
60
|
+
key: str
|
|
61
|
+
size: int
|
|
62
|
+
etag: str
|
|
63
|
+
|
|
64
|
+
def read(self, offset: int, length: int) -> bytes:
|
|
65
|
+
...
|
|
66
|
+
|
|
67
|
+
def close(self) -> None:
|
|
68
|
+
...
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class WriteStream(object):
|
|
72
|
+
bucket: str
|
|
73
|
+
key: str
|
|
74
|
+
storage_class: Optional[str]
|
|
75
|
+
|
|
76
|
+
def write(self, data: bytes) -> int:
|
|
77
|
+
...
|
|
78
|
+
|
|
79
|
+
def close(self) -> None:
|
|
80
|
+
...
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class TosError(object):
|
|
84
|
+
message: str
|
|
85
|
+
status_code: Optional[int]
|
|
86
|
+
ec: str
|
|
87
|
+
request_id: str
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class TosException(Exception):
|
|
91
|
+
args: List[TosError]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class TosRawClient(object):
|
|
95
|
+
region: str
|
|
96
|
+
endpoint: str
|
|
97
|
+
ak: str
|
|
98
|
+
sk: str
|
|
99
|
+
connection_timeout: int
|
|
100
|
+
request_timeout: int
|
|
101
|
+
max_connections: int
|
|
102
|
+
max_retry_count: int
|
|
103
|
+
|
|
104
|
+
def __init__(self, region: str, endpoint: str, ak: str = '', sk: str = '', connection_timeout: int = 10000,
|
|
105
|
+
request_timeout: int = 120000, max_connections: int = 1024, max_retry_count: int = 3):
|
|
106
|
+
...
|
|
107
|
+
|
|
108
|
+
def head_object(self, input: HeadObjectInput) -> HeadObjectOutput:
|
|
109
|
+
...
|
|
110
|
+
|
|
111
|
+
def delete_object(self, input: DeleteObjectInput) -> DeleteObjectOutput:
|
|
112
|
+
...
|
|
113
|
+
|
|
114
|
+
def get_object(self, input: GetObjectInput) -> GetObjectOutput:
|
|
115
|
+
...
|
|
116
|
+
|
|
117
|
+
def put_object_from_buffer(self, input: PutObjectFromBufferInput) -> PutObjectOutput:
|
|
118
|
+
...
|
|
119
|
+
|
|
120
|
+
def put_object_from_file(self, input: PutObjectFromFileInput) -> PutObjectOutput:
|
|
121
|
+
...
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class HeadObjectInput(object):
|
|
125
|
+
bucket: str
|
|
126
|
+
key: str
|
|
127
|
+
version_id: str
|
|
128
|
+
|
|
129
|
+
def __init__(self, bucket: str, key: str, version_id: str = ''):
|
|
130
|
+
...
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class HeadObjectOutput(object):
|
|
134
|
+
request_id: str
|
|
135
|
+
status_code: int
|
|
136
|
+
header: Dict[str, str]
|
|
137
|
+
content_length: int
|
|
138
|
+
etag: str
|
|
139
|
+
version_id: str
|
|
140
|
+
hash_crc64ecma: int
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class DeleteObjectInput(object):
|
|
144
|
+
bucket: str
|
|
145
|
+
key: str
|
|
146
|
+
version_id: str
|
|
147
|
+
|
|
148
|
+
def __init__(self, bucket: str, key: str, version_id: str = ''):
|
|
149
|
+
...
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class DeleteObjectOutput(object):
|
|
153
|
+
request_id: str
|
|
154
|
+
status_code: int
|
|
155
|
+
header: Dict[str, str]
|
|
156
|
+
delete_marker: bool
|
|
157
|
+
version_id: str
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class GetObjectInput(object):
|
|
161
|
+
bucket: str
|
|
162
|
+
key: str
|
|
163
|
+
version_id: str
|
|
164
|
+
range: str
|
|
165
|
+
|
|
166
|
+
def __init__(self, bucket: str, key: str, version_id: str = '', range: str = ''):
|
|
167
|
+
...
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class GetObjectOutput(object):
|
|
171
|
+
request_id: str
|
|
172
|
+
status_code: int
|
|
173
|
+
header: Dict[str, str]
|
|
174
|
+
content_length: int
|
|
175
|
+
etag: str
|
|
176
|
+
version_id: str
|
|
177
|
+
content_range: str
|
|
178
|
+
hash_crc64ecma: int
|
|
179
|
+
|
|
180
|
+
def read_all(self) -> bytes:
|
|
181
|
+
...
|
|
182
|
+
|
|
183
|
+
def read(self) -> bytes:
|
|
184
|
+
...
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class PutObjectFromBufferInput(object):
|
|
188
|
+
bucket: str
|
|
189
|
+
key: str
|
|
190
|
+
content: bytes
|
|
191
|
+
|
|
192
|
+
def __init__(self, bucket: str, key: str, content: bytes):
|
|
193
|
+
...
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class PutObjectFromFileInput(object):
|
|
197
|
+
bucket: str
|
|
198
|
+
key: str
|
|
199
|
+
file_path: str
|
|
200
|
+
|
|
201
|
+
def __init__(self, bucket: str, key: str, file_path: str):
|
|
202
|
+
...
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
class PutObjectOutput(object):
|
|
206
|
+
request_id: str
|
|
207
|
+
status_code: int
|
|
208
|
+
header: Dict[str, str]
|
|
209
|
+
etag: str
|
|
210
|
+
version_id: str
|
|
211
|
+
hash_crc64ecma: int
|
|
@@ -3,6 +3,11 @@ use crate::read_stream::ReadStream;
|
|
|
3
3
|
use crate::tos_client::TosClient;
|
|
4
4
|
use crate::tos_error::{TosError, TosException};
|
|
5
5
|
use crate::tos_model::{ListObjectsResult, TosObject};
|
|
6
|
+
use crate::tos_raw_client::{
|
|
7
|
+
DeleteObjectInput, DeleteObjectOutput, GetObjectInput, GetObjectOutput, HeadObjectInput,
|
|
8
|
+
HeadObjectOutput, PutObjectFromBufferInput, PutObjectFromFileInput, PutObjectOutput,
|
|
9
|
+
TosRawClient,
|
|
10
|
+
};
|
|
6
11
|
use crate::write_stream::WriteStream;
|
|
7
12
|
use pyo3::prelude::*;
|
|
8
13
|
|
|
@@ -11,11 +16,22 @@ mod read_stream;
|
|
|
11
16
|
mod tos_client;
|
|
12
17
|
mod tos_error;
|
|
13
18
|
mod tos_model;
|
|
19
|
+
mod tos_raw_client;
|
|
14
20
|
mod write_stream;
|
|
15
21
|
|
|
16
22
|
#[pymodule]
|
|
17
23
|
#[pyo3(name = "tosnativeclient")]
|
|
18
24
|
fn main(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
25
|
+
m.add_class::<TosRawClient>()?;
|
|
26
|
+
m.add_class::<HeadObjectInput>()?;
|
|
27
|
+
m.add_class::<HeadObjectOutput>()?;
|
|
28
|
+
m.add_class::<DeleteObjectInput>()?;
|
|
29
|
+
m.add_class::<DeleteObjectOutput>()?;
|
|
30
|
+
m.add_class::<GetObjectInput>()?;
|
|
31
|
+
m.add_class::<GetObjectOutput>()?;
|
|
32
|
+
m.add_class::<PutObjectFromBufferInput>()?;
|
|
33
|
+
m.add_class::<PutObjectFromFileInput>()?;
|
|
34
|
+
m.add_class::<PutObjectOutput>()?;
|
|
19
35
|
m.add_class::<TosClient>()?;
|
|
20
36
|
m.add_class::<ListStream>()?;
|
|
21
37
|
m.add_class::<ListObjectsResult>()?;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::tos_client::InnerTosClient;
|
|
2
|
-
use crate::tos_error::{
|
|
2
|
+
use crate::tos_error::{map_error_from_string, map_tos_error};
|
|
3
3
|
use crate::tos_model::ListObjectsResult;
|
|
4
4
|
use arc_swap::ArcSwap;
|
|
5
5
|
use async_channel::Receiver;
|
|
@@ -187,7 +187,7 @@ impl ListStream {
|
|
|
187
187
|
None => Ok(None),
|
|
188
188
|
Some(pg) => {
|
|
189
189
|
match pg.has_next() {
|
|
190
|
-
Err(ex) => return Err(
|
|
190
|
+
Err(ex) => return Err(map_tos_error(ex)),
|
|
191
191
|
Ok(has_next) => {
|
|
192
192
|
if !has_next {
|
|
193
193
|
return Ok(None);
|
|
@@ -199,7 +199,7 @@ impl ListStream {
|
|
|
199
199
|
self.runtime.block_on(async {
|
|
200
200
|
match pg.next_page().await {
|
|
201
201
|
Ok(output) => Ok(Some(ListObjectsResult::new(output))),
|
|
202
|
-
Err(ex) => Err(
|
|
202
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
203
203
|
}
|
|
204
204
|
})
|
|
205
205
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::tos_client::{InnerTosClient, SharedPrefetchContext};
|
|
2
|
-
use crate::tos_error::
|
|
2
|
+
use crate::tos_error::map_tos_error;
|
|
3
3
|
use crate::tos_model::TosObject;
|
|
4
4
|
use async_channel::{Receiver, Sender};
|
|
5
5
|
use bytes::Bytes;
|
|
@@ -52,7 +52,7 @@ impl ReadStream {
|
|
|
52
52
|
.py()
|
|
53
53
|
.allow_threads(|| runtime.block_on(async move { fetcher.read(offset, length).await }))
|
|
54
54
|
{
|
|
55
|
-
Err(ex) => Err(
|
|
55
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
56
56
|
Ok(result) => match result {
|
|
57
57
|
None => Ok(None),
|
|
58
58
|
Some(data) => Ok(Some(PyBytes::new(slf.py(), data.as_ref()))),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
use crate::list_stream::ListStream;
|
|
2
2
|
use crate::read_stream::ReadStream;
|
|
3
|
-
use crate::tos_error::
|
|
3
|
+
use crate::tos_error::map_tos_error;
|
|
4
4
|
use crate::tos_model::TosObject;
|
|
5
5
|
use crate::write_stream::WriteStream;
|
|
6
6
|
use async_trait::async_trait;
|
|
@@ -118,7 +118,7 @@ impl TosClient {
|
|
|
118
118
|
})
|
|
119
119
|
.build()
|
|
120
120
|
{
|
|
121
|
-
Err(ex) => return Err(
|
|
121
|
+
Err(ex) => return Err(map_tos_error(ex)),
|
|
122
122
|
Ok(client) => {
|
|
123
123
|
clients.push(client);
|
|
124
124
|
}
|
|
@@ -165,7 +165,7 @@ impl TosClient {
|
|
|
165
165
|
slf.py().allow_threads(|| {
|
|
166
166
|
runtime.block_on(async move {
|
|
167
167
|
match client.head_object(&input).await {
|
|
168
|
-
Err(ex) => Err(
|
|
168
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
169
169
|
Ok(output) => Ok(TosObject::new(input.bucket(), input.key(), output)),
|
|
170
170
|
}
|
|
171
171
|
})
|
|
@@ -201,7 +201,7 @@ impl TosClient {
|
|
|
201
201
|
storage_class,
|
|
202
202
|
self.part_size,
|
|
203
203
|
) {
|
|
204
|
-
Err(ex) => Err(
|
|
204
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
205
205
|
Ok(ws) => Ok(ws),
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
use pyo3::exceptions::PyException;
|
|
2
2
|
use pyo3::{create_exception, pyclass, pymethods, PyErr};
|
|
3
|
+
use std::error::Error;
|
|
3
4
|
|
|
4
5
|
#[pyclass]
|
|
5
6
|
#[derive(Clone)]
|
|
@@ -55,7 +56,11 @@ pub(crate) fn map_error_from_string(message: impl Into<String>) -> PyErr {
|
|
|
55
56
|
))
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
pub(crate) fn map_error(err:
|
|
59
|
+
pub(crate) fn map_error(err: impl Error) -> PyErr {
|
|
60
|
+
PyErr::new::<TosException, _>(TosError::message(err.to_string()))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
pub(crate) fn map_tos_error(err: ve_tos_rust_sdk::error::TosError) -> PyErr {
|
|
59
64
|
match err {
|
|
60
65
|
ve_tos_rust_sdk::error::TosError::TosClientError { message, .. } => {
|
|
61
66
|
PyErr::new::<TosException, _>(TosError::message(message))
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
use crate::tos_client::{InnerTosClient, TokioRuntime};
|
|
2
|
+
use crate::tos_error::{map_error, map_tos_error};
|
|
3
|
+
use bytes::Buf;
|
|
4
|
+
use futures_util::StreamExt;
|
|
5
|
+
use pyo3::{pyclass, pymethods, PyRef, PyRefMut, PyResult};
|
|
6
|
+
use std::collections::HashMap;
|
|
7
|
+
use std::sync::Arc;
|
|
8
|
+
use tokio::runtime;
|
|
9
|
+
use tokio::runtime::Runtime;
|
|
10
|
+
use tokio::sync::Mutex;
|
|
11
|
+
use ve_tos_rust_sdk::asynchronous::object::{ObjectAPI, ObjectContent};
|
|
12
|
+
use ve_tos_rust_sdk::asynchronous::tos;
|
|
13
|
+
|
|
14
|
+
#[pyclass(name = "TosRawClient")]
|
|
15
|
+
pub struct TosRawClient {
|
|
16
|
+
client: Arc<InnerTosClient>,
|
|
17
|
+
runtime: Arc<Runtime>,
|
|
18
|
+
#[pyo3(get)]
|
|
19
|
+
region: String,
|
|
20
|
+
#[pyo3(get)]
|
|
21
|
+
endpoint: String,
|
|
22
|
+
#[pyo3(get)]
|
|
23
|
+
ak: String,
|
|
24
|
+
#[pyo3(get)]
|
|
25
|
+
sk: String,
|
|
26
|
+
#[pyo3(get)]
|
|
27
|
+
connection_timeout: isize,
|
|
28
|
+
#[pyo3(get)]
|
|
29
|
+
request_timeout: isize,
|
|
30
|
+
#[pyo3(get)]
|
|
31
|
+
max_connections: isize,
|
|
32
|
+
#[pyo3(get)]
|
|
33
|
+
max_retry_count: isize,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#[pymethods]
|
|
37
|
+
impl TosRawClient {
|
|
38
|
+
#[new]
|
|
39
|
+
#[pyo3(signature = (region, endpoint, ak="", sk="", connection_timeout=10000, request_timeout=120000, max_connections=1024, max_retry_count=3)
|
|
40
|
+
)]
|
|
41
|
+
pub fn new(
|
|
42
|
+
region: &str,
|
|
43
|
+
endpoint: &str,
|
|
44
|
+
ak: &str,
|
|
45
|
+
sk: &str,
|
|
46
|
+
connection_timeout: isize,
|
|
47
|
+
request_timeout: isize,
|
|
48
|
+
max_connections: isize,
|
|
49
|
+
max_retry_count: isize,
|
|
50
|
+
) -> PyResult<Self> {
|
|
51
|
+
let runtime = Arc::new(runtime::Builder::new_multi_thread().enable_all().build()?);
|
|
52
|
+
match tos::builder()
|
|
53
|
+
.connection_timeout(connection_timeout)
|
|
54
|
+
.request_timeout(request_timeout)
|
|
55
|
+
.max_connections(max_connections)
|
|
56
|
+
.max_retry_count(max_retry_count)
|
|
57
|
+
.ak(ak)
|
|
58
|
+
.sk(sk)
|
|
59
|
+
.region(region)
|
|
60
|
+
.endpoint(endpoint)
|
|
61
|
+
.async_sleeper(TokioRuntime {
|
|
62
|
+
runtime: Some(runtime.clone()),
|
|
63
|
+
})
|
|
64
|
+
.build()
|
|
65
|
+
{
|
|
66
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
67
|
+
Ok(client) => Ok(Self {
|
|
68
|
+
client: Arc::new(client),
|
|
69
|
+
runtime,
|
|
70
|
+
region: region.to_string(),
|
|
71
|
+
endpoint: endpoint.to_string(),
|
|
72
|
+
ak: ak.to_string(),
|
|
73
|
+
sk: sk.to_string(),
|
|
74
|
+
connection_timeout,
|
|
75
|
+
request_timeout,
|
|
76
|
+
max_connections,
|
|
77
|
+
max_retry_count,
|
|
78
|
+
}),
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
pub fn head_object<'py>(
|
|
82
|
+
slf: PyRef<'_, Self>,
|
|
83
|
+
input: &HeadObjectInput,
|
|
84
|
+
) -> PyResult<HeadObjectOutput> {
|
|
85
|
+
let input = ve_tos_rust_sdk::object::HeadObjectInput::new_with_version_id(
|
|
86
|
+
&input.bucket,
|
|
87
|
+
&input.key,
|
|
88
|
+
&input.version_id,
|
|
89
|
+
);
|
|
90
|
+
let client = slf.client.clone();
|
|
91
|
+
let runtime = slf.runtime.clone();
|
|
92
|
+
slf.py().allow_threads(|| {
|
|
93
|
+
runtime.block_on(async move {
|
|
94
|
+
match client.head_object(&input).await {
|
|
95
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
96
|
+
Ok(output) => Ok(HeadObjectOutput {
|
|
97
|
+
request_id: output.request_id().to_string(),
|
|
98
|
+
status_code: output.status_code(),
|
|
99
|
+
header: output.header().clone(),
|
|
100
|
+
content_length: output.content_length(),
|
|
101
|
+
etag: output.etag().to_string(),
|
|
102
|
+
version_id: output.version_id().to_string(),
|
|
103
|
+
hash_crc64ecma: output.hash_crc64ecma(),
|
|
104
|
+
}),
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
pub fn delete_object(
|
|
111
|
+
slf: PyRef<'_, Self>,
|
|
112
|
+
input: &DeleteObjectInput,
|
|
113
|
+
) -> PyResult<DeleteObjectOutput> {
|
|
114
|
+
let input = ve_tos_rust_sdk::object::DeleteObjectInput::new_with_version_id(
|
|
115
|
+
&input.bucket,
|
|
116
|
+
&input.key,
|
|
117
|
+
&input.version_id,
|
|
118
|
+
);
|
|
119
|
+
let client = slf.client.clone();
|
|
120
|
+
let runtime = slf.runtime.clone();
|
|
121
|
+
slf.py().allow_threads(|| {
|
|
122
|
+
runtime.block_on(async move {
|
|
123
|
+
match client.delete_object(&input).await {
|
|
124
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
125
|
+
Ok(output) => Ok(DeleteObjectOutput {
|
|
126
|
+
request_id: output.request_id().to_string(),
|
|
127
|
+
status_code: output.status_code(),
|
|
128
|
+
header: output.header().clone(),
|
|
129
|
+
delete_marker: output.delete_marker(),
|
|
130
|
+
version_id: output.version_id().to_string(),
|
|
131
|
+
}),
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
pub fn get_object(slf: PyRef<'_, Self>, input: &GetObjectInput) -> PyResult<GetObjectOutput> {
|
|
138
|
+
let mut rinput = ve_tos_rust_sdk::object::GetObjectInput::new_with_version_id(
|
|
139
|
+
&input.bucket,
|
|
140
|
+
&input.key,
|
|
141
|
+
&input.version_id,
|
|
142
|
+
);
|
|
143
|
+
rinput.set_range(&input.range);
|
|
144
|
+
|
|
145
|
+
let client = slf.client.clone();
|
|
146
|
+
let runtime = slf.runtime.clone();
|
|
147
|
+
slf.py().allow_threads(|| {
|
|
148
|
+
runtime.clone().block_on(async move {
|
|
149
|
+
match client.get_object(&rinput).await {
|
|
150
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
151
|
+
Ok(output) => Ok(GetObjectOutput {
|
|
152
|
+
request_id: output.request_id().to_string(),
|
|
153
|
+
status_code: output.status_code(),
|
|
154
|
+
header: output.header().clone(),
|
|
155
|
+
content_length: output.content_length(),
|
|
156
|
+
etag: output.etag().to_string(),
|
|
157
|
+
version_id: output.version_id().to_string(),
|
|
158
|
+
content_range: output.content_range().to_string(),
|
|
159
|
+
hash_crc64ecma: output.hash_crc64ecma(),
|
|
160
|
+
output: Arc::new(Mutex::new(output)),
|
|
161
|
+
runtime: runtime.clone(),
|
|
162
|
+
}),
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
pub fn put_object_from_buffer(
|
|
169
|
+
slf: PyRef<'_, Self>,
|
|
170
|
+
input: &PutObjectFromBufferInput,
|
|
171
|
+
) -> PyResult<PutObjectOutput> {
|
|
172
|
+
let mut rinput =
|
|
173
|
+
ve_tos_rust_sdk::object::PutObjectFromBufferInput::new(&input.bucket, &input.key);
|
|
174
|
+
if input.content.len() > 0 {
|
|
175
|
+
rinput.set_content(input.content.as_slice());
|
|
176
|
+
}
|
|
177
|
+
let client = slf.client.clone();
|
|
178
|
+
let runtime = slf.runtime.clone();
|
|
179
|
+
slf.py().allow_threads(|| {
|
|
180
|
+
runtime.clone().block_on(async move {
|
|
181
|
+
match client.put_object_from_buffer(&rinput).await {
|
|
182
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
183
|
+
Ok(output) => Ok(PutObjectOutput {
|
|
184
|
+
request_id: output.request_id().to_string(),
|
|
185
|
+
status_code: output.status_code(),
|
|
186
|
+
header: output.header().clone(),
|
|
187
|
+
etag: output.etag().to_string(),
|
|
188
|
+
version_id: output.version_id().to_string(),
|
|
189
|
+
hash_crc64ecma: output.hash_crc64ecma(),
|
|
190
|
+
}),
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
pub fn put_object_from_file(
|
|
197
|
+
slf: PyRef<'_, Self>,
|
|
198
|
+
input: &PutObjectFromFileInput,
|
|
199
|
+
) -> PyResult<PutObjectOutput> {
|
|
200
|
+
let mut rinput =
|
|
201
|
+
ve_tos_rust_sdk::object::PutObjectFromFileInput::new(&input.bucket, &input.key);
|
|
202
|
+
rinput.set_file_path(&input.file_path);
|
|
203
|
+
let client = slf.client.clone();
|
|
204
|
+
let runtime = slf.runtime.clone();
|
|
205
|
+
slf.py().allow_threads(|| {
|
|
206
|
+
runtime.clone().block_on(async move {
|
|
207
|
+
match client.put_object_from_file(&rinput).await {
|
|
208
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
209
|
+
Ok(output) => Ok(PutObjectOutput {
|
|
210
|
+
request_id: output.request_id().to_string(),
|
|
211
|
+
status_code: output.status_code(),
|
|
212
|
+
header: output.header().clone(),
|
|
213
|
+
etag: output.etag().to_string(),
|
|
214
|
+
version_id: output.version_id().to_string(),
|
|
215
|
+
hash_crc64ecma: output.hash_crc64ecma(),
|
|
216
|
+
}),
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
#[pyclass(name = "HeadObjectInput")]
|
|
224
|
+
pub struct HeadObjectInput {
|
|
225
|
+
#[pyo3(get, set)]
|
|
226
|
+
pub(crate) bucket: String,
|
|
227
|
+
#[pyo3(get, set)]
|
|
228
|
+
pub(crate) key: String,
|
|
229
|
+
#[pyo3(get, set)]
|
|
230
|
+
pub(crate) version_id: String,
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#[pymethods]
|
|
234
|
+
impl HeadObjectInput {
|
|
235
|
+
#[new]
|
|
236
|
+
#[pyo3(signature = (bucket, key, version_id = ""))]
|
|
237
|
+
pub fn new(bucket: &str, key: &str, version_id: &str) -> PyResult<Self> {
|
|
238
|
+
Ok(Self {
|
|
239
|
+
bucket: bucket.to_string(),
|
|
240
|
+
key: key.to_string(),
|
|
241
|
+
version_id: version_id.to_string(),
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
#[pyclass(name = "HeadObjectOutput")]
|
|
247
|
+
pub struct HeadObjectOutput {
|
|
248
|
+
#[pyo3(get)]
|
|
249
|
+
pub(crate) request_id: String,
|
|
250
|
+
#[pyo3(get)]
|
|
251
|
+
pub(crate) status_code: isize,
|
|
252
|
+
#[pyo3(get)]
|
|
253
|
+
pub(crate) header: HashMap<String, String>,
|
|
254
|
+
#[pyo3(get)]
|
|
255
|
+
pub(crate) content_length: i64,
|
|
256
|
+
#[pyo3(get)]
|
|
257
|
+
pub(crate) etag: String,
|
|
258
|
+
#[pyo3(get)]
|
|
259
|
+
pub(crate) version_id: String,
|
|
260
|
+
#[pyo3(get)]
|
|
261
|
+
pub(crate) hash_crc64ecma: u64,
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
#[pyclass(name = "DeleteObjectInput")]
|
|
265
|
+
pub struct DeleteObjectInput {
|
|
266
|
+
#[pyo3(get, set)]
|
|
267
|
+
pub(crate) bucket: String,
|
|
268
|
+
#[pyo3(get, set)]
|
|
269
|
+
pub(crate) key: String,
|
|
270
|
+
#[pyo3(get, set)]
|
|
271
|
+
pub(crate) version_id: String,
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
#[pymethods]
|
|
275
|
+
impl DeleteObjectInput {
|
|
276
|
+
#[new]
|
|
277
|
+
#[pyo3(signature = (bucket, key, version_id = ""))]
|
|
278
|
+
pub fn new(bucket: &str, key: &str, version_id: &str) -> PyResult<Self> {
|
|
279
|
+
Ok(Self {
|
|
280
|
+
bucket: bucket.to_string(),
|
|
281
|
+
key: key.to_string(),
|
|
282
|
+
version_id: version_id.to_string(),
|
|
283
|
+
})
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
#[pyclass(name = "DeleteObjectOutput")]
|
|
288
|
+
pub struct DeleteObjectOutput {
|
|
289
|
+
#[pyo3(get)]
|
|
290
|
+
pub(crate) request_id: String,
|
|
291
|
+
#[pyo3(get)]
|
|
292
|
+
pub(crate) status_code: isize,
|
|
293
|
+
#[pyo3(get)]
|
|
294
|
+
pub(crate) header: HashMap<String, String>,
|
|
295
|
+
#[pyo3(get)]
|
|
296
|
+
pub(crate) delete_marker: bool,
|
|
297
|
+
#[pyo3(get)]
|
|
298
|
+
pub(crate) version_id: String,
|
|
299
|
+
}
|
|
300
|
+
#[pyclass(name = "GetObjectInput")]
|
|
301
|
+
pub struct GetObjectInput {
|
|
302
|
+
#[pyo3(get, set)]
|
|
303
|
+
pub(crate) bucket: String,
|
|
304
|
+
#[pyo3(get, set)]
|
|
305
|
+
pub(crate) key: String,
|
|
306
|
+
#[pyo3(get, set)]
|
|
307
|
+
pub(crate) version_id: String,
|
|
308
|
+
#[pyo3(get, set)]
|
|
309
|
+
pub(crate) range: String,
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
#[pymethods]
|
|
313
|
+
impl GetObjectInput {
|
|
314
|
+
#[new]
|
|
315
|
+
#[pyo3(signature = (bucket, key, version_id = "", range = ""))]
|
|
316
|
+
pub fn new(bucket: &str, key: &str, version_id: &str, range: &str) -> PyResult<Self> {
|
|
317
|
+
Ok(Self {
|
|
318
|
+
bucket: bucket.to_string(),
|
|
319
|
+
key: key.to_string(),
|
|
320
|
+
version_id: version_id.to_string(),
|
|
321
|
+
range: range.to_string(),
|
|
322
|
+
})
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
#[pyclass(name = "GetObjectOutput")]
|
|
327
|
+
pub struct GetObjectOutput {
|
|
328
|
+
#[pyo3(get)]
|
|
329
|
+
pub(crate) request_id: String,
|
|
330
|
+
#[pyo3(get)]
|
|
331
|
+
pub(crate) status_code: isize,
|
|
332
|
+
#[pyo3(get)]
|
|
333
|
+
pub(crate) header: HashMap<String, String>,
|
|
334
|
+
#[pyo3(get)]
|
|
335
|
+
pub(crate) content_length: i64,
|
|
336
|
+
#[pyo3(get)]
|
|
337
|
+
pub(crate) etag: String,
|
|
338
|
+
#[pyo3(get)]
|
|
339
|
+
pub(crate) version_id: String,
|
|
340
|
+
#[pyo3(get)]
|
|
341
|
+
pub(crate) content_range: String,
|
|
342
|
+
#[pyo3(get)]
|
|
343
|
+
pub(crate) hash_crc64ecma: u64,
|
|
344
|
+
output: Arc<Mutex<ve_tos_rust_sdk::object::GetObjectOutput>>,
|
|
345
|
+
runtime: Arc<Runtime>,
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
#[pymethods]
|
|
349
|
+
impl GetObjectOutput {
|
|
350
|
+
pub fn read_all(slf: PyRefMut<'_, Self>) -> PyResult<Option<Vec<u8>>> {
|
|
351
|
+
let runtime = slf.runtime.clone();
|
|
352
|
+
let output = slf.output.clone();
|
|
353
|
+
runtime.block_on(async move {
|
|
354
|
+
match output.lock().await.read_all().await {
|
|
355
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
356
|
+
Ok(buf) => Ok(Some(buf)),
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
pub fn read(slf: PyRefMut<'_, Self>) -> PyResult<Option<Vec<u8>>> {
|
|
362
|
+
let runtime = slf.runtime.clone();
|
|
363
|
+
let output = slf.output.clone();
|
|
364
|
+
runtime.block_on(async move {
|
|
365
|
+
match output.lock().await.next().await {
|
|
366
|
+
None => Ok(None),
|
|
367
|
+
Some(result) => match result {
|
|
368
|
+
Err(ex) => Err(map_error(ex)),
|
|
369
|
+
Ok(buf) => Ok(Some(buf.chunk().to_vec())),
|
|
370
|
+
},
|
|
371
|
+
}
|
|
372
|
+
})
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
#[pyclass(name = "PutObjectFromBufferInput")]
|
|
377
|
+
pub struct PutObjectFromBufferInput {
|
|
378
|
+
#[pyo3(get, set)]
|
|
379
|
+
pub(crate) bucket: String,
|
|
380
|
+
#[pyo3(get, set)]
|
|
381
|
+
pub(crate) key: String,
|
|
382
|
+
#[pyo3(get, set)]
|
|
383
|
+
pub(crate) content: Vec<u8>,
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
#[pymethods]
|
|
387
|
+
impl PutObjectFromBufferInput {
|
|
388
|
+
#[new]
|
|
389
|
+
#[pyo3(signature = (bucket, key, content))]
|
|
390
|
+
pub fn new(bucket: &str, key: &str, content: &[u8]) -> PyResult<Self> {
|
|
391
|
+
Ok(Self {
|
|
392
|
+
bucket: bucket.to_string(),
|
|
393
|
+
key: key.to_string(),
|
|
394
|
+
content: content.to_vec(),
|
|
395
|
+
})
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
#[pyclass(name = "PutObjectFromFileInput")]
|
|
400
|
+
pub struct PutObjectFromFileInput {
|
|
401
|
+
#[pyo3(get, set)]
|
|
402
|
+
pub(crate) bucket: String,
|
|
403
|
+
#[pyo3(get, set)]
|
|
404
|
+
pub(crate) key: String,
|
|
405
|
+
#[pyo3(get, set)]
|
|
406
|
+
pub(crate) file_path: String,
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
#[pymethods]
|
|
410
|
+
impl PutObjectFromFileInput {
|
|
411
|
+
#[new]
|
|
412
|
+
#[pyo3(signature = (bucket, key, file_path))]
|
|
413
|
+
pub fn new(bucket: &str, key: &str, file_path: &str) -> PyResult<Self> {
|
|
414
|
+
Ok(Self {
|
|
415
|
+
bucket: bucket.to_string(),
|
|
416
|
+
key: key.to_string(),
|
|
417
|
+
file_path: file_path.to_string(),
|
|
418
|
+
})
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
#[pyclass(name = "PutObjectOutput")]
|
|
423
|
+
pub struct PutObjectOutput {
|
|
424
|
+
#[pyo3(get)]
|
|
425
|
+
pub(crate) request_id: String,
|
|
426
|
+
#[pyo3(get)]
|
|
427
|
+
pub(crate) status_code: isize,
|
|
428
|
+
#[pyo3(get)]
|
|
429
|
+
pub(crate) header: HashMap<String, String>,
|
|
430
|
+
#[pyo3(get)]
|
|
431
|
+
pub(crate) etag: String,
|
|
432
|
+
#[pyo3(get)]
|
|
433
|
+
pub(crate) version_id: String,
|
|
434
|
+
#[pyo3(get)]
|
|
435
|
+
pub(crate) hash_crc64ecma: u64,
|
|
436
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::tos_client::InnerTosClient;
|
|
2
|
-
use crate::tos_error::
|
|
2
|
+
use crate::tos_error::map_tos_error;
|
|
3
3
|
use async_channel::{Receiver, Sender};
|
|
4
4
|
use futures_util::future::join_all;
|
|
5
5
|
use pyo3::{pyclass, pymethods, PyRefMut, PyResult};
|
|
@@ -52,7 +52,7 @@ impl WriteStream {
|
|
|
52
52
|
.py()
|
|
53
53
|
.allow_threads(|| runtime.block_on(async move { writer.write(data, offset).await }))
|
|
54
54
|
{
|
|
55
|
-
Err(ex) => Err(
|
|
55
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
56
56
|
Ok(written) => {
|
|
57
57
|
slf.offset += written;
|
|
58
58
|
Ok(written)
|
|
@@ -67,7 +67,7 @@ impl WriteStream {
|
|
|
67
67
|
.py()
|
|
68
68
|
.allow_threads(|| runtime.block_on(async move { writer.release().await }))
|
|
69
69
|
{
|
|
70
|
-
Err(ex) => Err(
|
|
70
|
+
Err(ex) => Err(map_tos_error(ex)),
|
|
71
71
|
Ok(_) => Ok(()),
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
from typing import List
|
|
2
|
-
|
|
3
|
-
from typing import Optional
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class TosClient(object):
|
|
7
|
-
region: str
|
|
8
|
-
endpoint: str
|
|
9
|
-
ak: str
|
|
10
|
-
sk: str
|
|
11
|
-
part_size: int
|
|
12
|
-
max_retry_count: int
|
|
13
|
-
max_prefetch_tasks: int
|
|
14
|
-
|
|
15
|
-
def __init__(self, region: str, endpoint: str, ak: str = '', sk: str = '', part_size: int = 8388608,
|
|
16
|
-
max_retry_count: int = 3, max_prefetch_tasks: int = 3, directives: str = '', directory: str = '',
|
|
17
|
-
file_name_prefix: str = '', shared_prefetch_tasks: int = 20):
|
|
18
|
-
...
|
|
19
|
-
|
|
20
|
-
def list_objects(self, bucket: str, prefix: str = '', max_keys: int = 1000, delimiter: str = '') -> ListStream:
|
|
21
|
-
...
|
|
22
|
-
|
|
23
|
-
def head_object(self, bucket: str, key: str) -> TosObject:
|
|
24
|
-
...
|
|
25
|
-
|
|
26
|
-
def get_object(self, bucket: str, key: str, etag: str, size: int) -> ReadStream:
|
|
27
|
-
...
|
|
28
|
-
|
|
29
|
-
def put_object(self, bucket: str, key: str, storage_class: str = '') -> WriteStream:
|
|
30
|
-
...
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class ListStream(object):
|
|
34
|
-
bucket: str
|
|
35
|
-
prefix: str
|
|
36
|
-
delimiter: str
|
|
37
|
-
max_keys: int
|
|
38
|
-
|
|
39
|
-
def __iter__(self) -> ListStream: ...
|
|
40
|
-
|
|
41
|
-
def __next__(self) -> ListObjectsResult: ...
|
|
42
|
-
|
|
43
|
-
def close(self) -> None: ...
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class ListObjectsResult(object):
|
|
47
|
-
contents: List[TosObject]
|
|
48
|
-
common_prefixes: List[str]
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class TosObject(object):
|
|
52
|
-
bucket: str
|
|
53
|
-
key: str
|
|
54
|
-
size: int
|
|
55
|
-
etag: str
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class ReadStream(object):
|
|
59
|
-
bucket: str
|
|
60
|
-
key: str
|
|
61
|
-
size: int
|
|
62
|
-
etag: str
|
|
63
|
-
|
|
64
|
-
def read(self, offset: int, length: int) -> bytes:
|
|
65
|
-
...
|
|
66
|
-
|
|
67
|
-
def close(self) -> None:
|
|
68
|
-
...
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
class WriteStream(object):
|
|
72
|
-
bucket: str
|
|
73
|
-
key: str
|
|
74
|
-
storage_class: Optional[str]
|
|
75
|
-
|
|
76
|
-
def write(self, data: bytes) -> int:
|
|
77
|
-
...
|
|
78
|
-
|
|
79
|
-
def close(self) -> None:
|
|
80
|
-
...
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
class TosError(object):
|
|
84
|
-
message: str
|
|
85
|
-
status_code: Optional[int]
|
|
86
|
-
ec: str
|
|
87
|
-
request_id: str
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
class TosException(Exception):
|
|
91
|
-
args: List[TosError]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|