Ошибка загрузки документов GCS с длинными именами файлов при пакетной обработке.Python

Программы на Python
Anonymous
Ошибка загрузки документов GCS с длинными именами файлов при пакетной обработке.

Сообщение Anonymous »

Загрузка документа с uri gs://xxxx/1.pdf работает, но gs://xxx/BNdVN44BwtVeYJ-Riplg-617aa6d594c951c3e9cca81712499f7a.pdf приводит к следующему:

Код: Выделить всё

Error: 400 Failed to process all documents. 3: Failed to process all documents. 
Не уверен, проблема ли это в кодировке или длине имени файла или как ее обойти. Закодировать имя файла с помощью urllib.parse.quote, как и с помощью библиотеки запросов, не помогло.
Я всегда могу скопировать файлы в новое место с короткими буквенно-цифровыми именами, но это не кажется оптимальным.

Код: Выделить всё

opts = ClientOptions(api_endpoint=f"{location}-documentai.googleapis.com")
doc_client = documentai.DocumentProcessorServiceClient(credentials=credentials, client_options=opts)
name = doc_client.processor_path(project_id, location, processor_id)

gcs_docs = []
for doc in documents:
filename = doc['@googlebackuplocation']
uri = f"gs://XXX/{filename}"
document = documentai.GcsDocument(gcs_uri=uri, mime_type="application/pdf")
gcs_docs.append(document)

gcs_documents = documentai.GcsDocuments(documents=gcs_docs)

input_config = documentai.BatchDocumentsInputConfig(gcs_documents=gcs_documents)
gcs_output_config = documentai.DocumentOutputConfig.GcsOutputConfig(
gcs_uri="gs://yyy/"
)
output_config = documentai.DocumentOutputConfig(gcs_output_config=gcs_output_config)

request = documentai.BatchProcessRequest(
name=name,
input_documents=input_config,
document_output_config=output_config
)

response = doc_client.batch_process_documents(request)
response.result(timeout=60)
`

Подробнее здесь: https://stackoverflow.com/questions/782 ... processing

Вернуться в «Python»