Skip to main content

clearcache

Краткая информация

Содержащит методы ввода-вывода, специфичные для облака.

Обсуждение

Этот класс не может быть запущен напрямую. Экземпляр этого класса возвращается свойством cloud объекта AIO.

Синтаксис

clearcache()

Методы

clearcache(path)

Очищает списки папок в памяти, свойства файлов и кэш региона BLOB. Вызовите этот метод, когда внешний процесс обновляет папки или файлы в облачном хранилище, к которым ранее осуществлялся доступ.

Имя Объяснение Тип данных

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()

Получает облачную конечную точку, указанную в соединении.

Возвращаемое значение

Тип данных Объяснение

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

Истина, если файл загружен успешно; в противном случае — Ложь.

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})

Создает временный URL-адрес, заданный HTTP.

Имя Объяснение Тип данных

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

URL-адрес, подписанный HTTP.

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

Истина, если файл загружен успешно; в противном случае — Ложь.

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})

Тестирует облачное соединение на предмет различных файловых операций. Доступные разрешения могут быть детализированными в зависимости от конфигурации 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)