CloudOp

摘要

包含特定于云的 IO 方法。

说明

此类无法直接实例化。 由 AIO 对象的 cloud 属性返回此类的实例。

方法概述

方法说明
clearcache (path)

清除内存中的目录列表、文件属性和 BLOB 区域缓存。 当外部进程更新云存储中以前访问过的文件夹或文件时,调用此方法。

getbucketname ()

获取连接的存储段或容器的名称。

getendpoint (path)

获取连接中指定的云端点。

getfile (src, dst, {options})

从云中下载文件。

getmetadata (path, {domain})

获取文件或文件夹的元数据。

getobjectstorepath ()

获取连接的根路径。

getproperties (path)

获取标题属性。

getprovidername ()

获取云提供商名称。

getprovideroptions ()

获取连接中指定的提供者选项。

getregion ()

获取连接中指定的云区域。

getsignedurl (path, expiry, {upload})

生成一个临时的 HTTP 预签名 URL。

putfile (src, dst, {options})

将文件上传到云端。

setmetadata (path, {domain}, {metadata}, {options})

设置文件或文件夹的元数据。

validate ({certificate}, {stat}, {list}, {read}, {modify}, {path})

测试各种文件操作的云连接。 根据服务器 ACL 配置,可用的权限可能十分细化。

方法

clearcache (path)
参数说明数据类型
path

The relative path from the current working directory or an absolute path (absolute vsi path for cloud).

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 (path)
参数说明数据类型
path

The relative path from the current working directory or an absolute path (absolute vsi path for cloud).

String
返回值
数据类型说明
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 vsi cloud path.

String
dst

The local, or target, path of the file.

String
options

Specifies the options that will be used.

  • RECURSIVE—Subdirectories and their contents will be recursively copied. This option is only applicable for folder operations.
  • SYNC_STRATEGY—The criteria that will be used for overwriting if the target file exists.
  • NUM_THREADS—The number of threads that will be used for parallel file copying.
  • CHUNK_SIZE—The maximum chunk size (in bytes) that will be used to split large objects when uploading or downloading.

Syntax—RECURSIVE=[YES|NO], SYNC_STRATEGY=[TIMESTAMP|ETAG|OVERWRITE], NUM_THREADS=(integer) CHUNK_SIZE=(integer) [x-amz-*|x-goog-*|x-ms-*=(value)]

Example—{'RECURSIVE':'YES', 'SYNC_STRATEGY':'OVERWRITE', 'NUM_THREADS':'10', 'CHUNK_SIZE':'8'}

(默认值为 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 vsi path for cloud).

String
domain

The metadata domain, for example, (https://gdal.org/api/cpl.html#_CPPv418VSIGetFileMetadataPKcPKc12CSLConstList).

(默认值为 None)

String
返回值
数据类型说明
Dictionary

元数据信息的字典。

此方法仅适用于云存储。

cloud_io = AIO(r"C:\data\datacloud.acs")
cloud_io.cloud.getmetadata(r'aio')
getobjectstorepath ()
返回值
数据类型说明
String

对象存储的 vsi 路径。

此方法仅适用于云存储。

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 vsi path for cloud).

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})
参数说明数据类型
path

The relative path from the current working directory or an absolute path (absolute vsi path for cloud).

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 vsi cloud path.

String
options

Specifies the options that will be used.

  • RECURSIVE—Subdirectories and their contents will be recursively copied. This option is only applicable to folder operations.
  • SYNC_STRATEGY—The criteria that will be used for overwriting if the target file exists.
  • NUM_THREADS—The number of threads that will be used for parallel file copying.
  • CHUNK_SIZE—The maximum chunk size (in bytes) that will be used to split large objects when uploading or downloading.

Syntax—RECURSIVE=[YES|NO], SYNC_STRATEGY=[TIMESTAMP|ETAG|OVERWRITE], NUM_THREADS=(integer) CHUNK_SIZE=(integer) [x-amz-*|x-goog-*|x-ms-*=(value)]

Example—{'RECURSIVE':'YES', 'SYNC_STRATEGY':'OVERWRITE', 'NUM_THREADS':'10', 'CHUNK_SIZE':'8'}

(默认值为 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 vsi path for cloud).

String
domain

The metadata domain, for example, (https://gdal.org/api/cpl.html#_CPPv418VSISetFileMetadataPKc12CSLConstListPKc12CSLConstList).

(默认值为 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})
参数说明数据类型
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)