clearcache
汇总
包含特定于云的 IO 方法。
讨论
此类无法直接实例化。 由 AIO 对象的 cloud 属性返回此类的实例。
语法
clearcache()
方法
clearcache(path)
清除内存中的目录列表、文件属性和 BLOB 区域缓存。 当外部进程更新云存储中以前访问过的文件夹或文件时,调用此方法。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
path |
The relative path from the current working directory or an absolute path (absolute |
String |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.clearcache(r"aio")
getbucketname()
获取连接的存储段或容器的名称。
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
存储段或容器的名称。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getbucketname()
getendpoint()
获取连接中指定的云端点。
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
云端点(如果可用)。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getendpoint()
getfile(src, dst, {options})
从云中下载文件。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
src |
The relative path from the current working directory or an absolute |
String |
|
dst |
The local, or target, path of the file. |
String |
|
options (可选) |
Specifies the options that will be used.
Syntax— Example— (默认值为 None) |
Dictionary |
返回值
| 数据类型 | 说明 |
|---|---|
|
Boolean |
如果文件成功下载,则为 True,否则为 False。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getfile(r'utf8_test.json', r"c:\data\datafile.json")
getmetadata(path, {domain})
获取文件或文件夹的元数据。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
path |
The relative path from the current working directory or an absolute path (absolute |
String |
|
domain (可选) |
The metadata domain, for example, (默认值为 None) |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
Dictionary |
元数据信息的字典。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getmetadata(r'aio')
getobjectstorepath()
获取连接的根路径。
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
对象存储的 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getobjectstorepath()
getproperties(path)
获取标题属性。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
path |
The relative path from the current working directory or an absolute path (absolute |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
Dictionary |
标题属性的字典。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getproperties(r'aio')
getprovidername()
获取云提供商名称。
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
云提供商名称。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getprovidername()
getprovideroptions()
获取连接中指定的提供者选项。
返回值
| 数据类型 | 说明 |
|---|---|
|
List |
提供者选项(如果可用)。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getprovideroptions()
getregion()
获取连接中指定的云区域。
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
云区域(如果可用)。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getregion()
getsignedurl(path, expiry, {upload})
生成一个临时的 HTTP 预签名 URL。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
path |
The relative path from the current working directory or an absolute path (absolute |
String |
|
expiry |
The expiry time in seconds. |
Integer |
|
upload (可选) |
Specifies whether the URL will be generated for upload. If True, the URL will be generated. (默认值为 False) |
Boolean |
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
HTTP 签名 URL。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getsignedurl(r'data.json', 5)
putfile(src, dst, {options})
将文件上传到云端。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
src |
The local (source) path of the file. |
String |
|
dst |
The relative path from the current working directory or an absolute |
String |
|
options (可选) |
Specifies the options that will be used.
Syntax— Example— (默认值为 None) |
Dictionary |
返回值
| 数据类型 | 说明 |
|---|---|
|
Boolean |
如果文件成功上传,则为 True,否则为 False。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.putfile(r"C:\data\data_file.json", r'data_folder\data_file_new.json')
setmetadata(path, {domain}, {metadata}, {options})
设置文件或文件夹的元数据。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
path |
The relative path from the current working directory or an absolute path (absolute |
String |
|
domain (可选) |
The metadata domain, for example, (默认值为 None) |
String |
|
metadata (可选) |
The metadata that will be set. (默认值为 None) |
Dictionary |
|
options (可选) |
The options that will be used to set the metadata. (默认值为 None) |
Dictionary |
返回值
| 数据类型 | 说明 |
|---|---|
|
Boolean |
如果元数据成功设置,则为 True,否则为 False。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.setmetadata(
r"cog.tif",
"HEADERS",
{
"x-amz-id-2": "HxM4BcALW+HnJ13owxzMpeQXXI59VKK3I9zujbqyLBCinCt6prnzKXR4Ixhb/AloFVJLGtuqKG7nSLCLaxObTw==",
"x-amz-request-id": "KYTDPC2WH2ZQK2D2",
"Date": "Tue, 13 Jun 2023 13:39:33 GMT",
"Last-Modified": "Wed, 16 Sep 2020 13:49:34 GMT",
"ETag": '"c220c099c46c60703de0c55763d04371"',
"x-amz-meta-s3b-last-modified": "20171213T210220Z",
"Content-Disposition": "attachment",
"Accept-Ranges": "bytes",
"Content-Range": "bytes 0-16383/4339079",
"Content-Type": "text/plain",
"Server": "AmazonS3",
"Content-Length": "4545",
},
)
validate({certificate}, {stat}, {list}, {read}, {modify}, {path})
测试各种文件操作的云连接。 根据服务器 ACL 配置,可用的权限可能十分细化。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
certificate (可选) |
Specifies whether the SSL certificate and Online Certificate Status Protocol (OCSP) certificate check will be verified. |
Boolean |
|
stat (可选) |
Specifies whether stat on the root container or connected folder will be tested. |
Boolean |
|
list (可选) |
Specifies whether list directory access will be tested. |
Boolean |
|
read (可选) |
Specifies whether the read file permission will be tested. |
Boolean |
|
modify (可选) |
Specifies whether the write and delete permissions will be tested. If delete access is denied, a test file will remain on the cloud. |
Boolean |
|
path (可选) |
The path to the file that will be used for the read test. If no value is provided, the first entry from the current directory listing will be used. |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
List |
测试结果和详细的错误消息(如果存在)。 |
cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.validate(True, True, True, True)