이 문서에서는 만들기, 가져오기, 업데이트, 삭제 작업을 비롯하여 Document AI Warehouse에서 문서를 관리하는 방법을 설명합니다.
문서란 무엇인가요?
문서는 Document AI Warehouse에서 실제 문서 (예: PDF 또는 TXT)와 연결된 속성을 구성하는 데 사용되는 데이터 모델입니다. 문서에 대한 작업을 통해 Document AI Warehouse와 상호작용합니다.
지원되는 파일 형식
Document AI Warehouse의 기본 대상은 문서이지만 연결된 이미지(예: 보험, 엔지니어링, 건설, 연구와 같은 업종)를 관리하는 데도 사용됩니다.
- Ingest API는 PDF와 TIFF, JPEG, PNG 이미지, 속성 또는 사전 추출된 텍스트를 지원합니다.
- 업로드 UI는 Document AI OCR 및 커스텀 프로세서를 사용하여 PDF 추출을 지원합니다.
- 뷰어 UI는 PDF, 텍스트, Microsoft Office 파일의 렌더링을 지원합니다.
시작하기 전에
시작하기 전에 빠른 시작 페이지를 완료했는지 확인하세요.
문서를 만들 때 데이터가 자체 Cloud Storage 버킷에 있는 경우 Document AI Warehouse 서비스 계정에 데이터 읽기 권한을 부여해야 합니다.
각 문서는 스키마로 지정되며 문서 유형에 속합니다. 문서 스키마는 Document AI Warehouse의 문서 구조를 정의합니다. 문서를 만들려면 먼저 문서 스키마를 만들어야 합니다.
문서 만들기
문서를 만들려면 Document AI Warehouse에 원시 문서 콘텐츠를 제공해야 합니다. 원시 문서 바이트 콘텐츠를 제공하는 두 가지 방법은 Document.inline_raw_document 또는 Document.raw_document_path를 설정하는 것입니다.
차이점은 다음과 같습니다.
Document.raw_document_path: 이 방법을 사용하는 것이 좋습니다. 수집할 파일의 Cloud Storage 경로 (gs://bucket/object)를 사용합니다. 호출이 성공하려면 호출자에게 이 객체에 대한 읽기 권한이 있어야 합니다.Document.inline_raw_document: 파일의 바이트/텍스트 표현으로, 엔드포인트에 직접 제공됩니다.
문서를 만들려면 다음 안내를 따르세요.
Cloud Storage에서 문서 업로드
기본 요건 섹션에 설명된 대로 Document AI Warehouse 서비스 계정에 Cloud Storage 버킷에 대한 액세스 권한을 부여해야 합니다.
안내에 따라 Cloud Storage 버킷에 파일을 업로드해야 합니다.
REST
요청:
curl --location --request POST --url https://contentwarehouse.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/documents \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-Type: application/json; charset=utf-8" \
--data '{
"document": {
"display_name": "TestDoc3",
"document_schema_name": "projects/PROJECT_NUMBER/locations/LOCATION/documentSchemas/DOCUMENT_SCHEMA_ID",
"raw_document_path": "gs://BUCKET_URI/FILE_URI",
"properties": [
{
"name": "supplier_name",
"text_values": {
"values": "Stanford Plumbing & Heating"
}
},
{
"name": "total_amount",
"float_values": {
"values": "1091.81"
}
},
]
},
"requestMetadata":{
"userInfo":{
"id": "user:USER_EMAIL_ID"
}
}
}'로컬 머신에서 업로드
REST
요청:
curl --location --request POST --url https://contentwarehouse.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/documents/ \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-Type: application/json; charset=utf-8" \
--data '{
"document": {
"display_name": "TestDoc3",
"document_schema_name": "projects/PROJECT_NUMBER/locations/LOCATION/documentSchemas/DOCUMENT_SCHEMA_ID",
"inline_raw_document": "<bytes>",
"properties": [
{
"name": "supplier_name",
"text_values": {
"values": "Stanford Plumbing & Heating"
}
},
{
"name": "total_amount",
"float_values": {
"values": "1091.81"
}
},
]
},
"requestMetadata": {
"userInfo": {
"id": "user:USER_EMAIL_ID"
}
}
}'문서 가져오기
document_id별:
REST
curl --request POST \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-Type: application/json; charset=UTF-8" -d '{
"requestMetadata":{
"userInfo":{
"id": "user:USER_EMAIL"
}
}
}' \
"https://contentwarehouse.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/documents/DOCUMENT_ID:get"Python
자세한 내용은 Document AI Warehouse Python API 참조 문서를 참조하세요.
Document AI Warehouse에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Java
자세한 내용은 Document AI Warehouse Java API 참조 문서를 참조하세요.
Document AI Warehouse에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Node.js
자세한 내용은 Document AI Warehouse Node.js API 참조 문서를 참조하세요.
Document AI Warehouse에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
reference_id별:
curl --request POST \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-Type: application/json; charset=UTF-8" -d '{
"requestMetadata":{
"userInfo":{
"id": "user:USER_EMAIL"
}
}
}' \
"https://contentwarehouse.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/documents/referenceId/REFERENCE_ID:get"문서 업데이트
document_id별:
REST
posix-terminal
curl --location --request POST --url https://contentwarehouse.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/documents \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-Type: application/json; charset=utf-8" \
--data '{
"document": {
"display_name": "TestDoc3",
"document_schema_name": "projects/PROJECT_NUMBER/locations/LOCATION/documentSchemas/DOCUMENT_SCHEMA_ID",
"raw_document_path": "gs://BUCKET_URI/FILE_URI",
"properties": [
{
"name": "supplier_name",
"text_values": {
"values": "Stanford Plumbing & Heating"
}
},
{
"name": "total_amount",
"float_values": {
"values": "1091.81"
}
},
{
"name": "invoice_id",
"text_values": {
"values": "invoiceid"
}
},
]
},
"requestMetadata": {
"userInfo": {
"id": "user:USER_EMAIL"
}
}
}'
Python
자세한 내용은 Document AI Warehouse Python API 참조 문서를 참조하세요.
Document AI Warehouse에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
Java
자세한 내용은 Document AI Warehouse Java API 참조 문서를 참조하세요.
Document AI Warehouse에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.
reference_id별:
curl --location --request POST --url https://contentwarehouse.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/documents \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-Type: application/json; charset=utf-8" \
--data '{
"document": {
"display_name": "TestDoc3",
"document_schema_name": "projects/PROJECT_NUMBER/locations/LOCATION/documentSchemas/referenceId/REFERENCE_ID",
"raw_document_path": "gs://BUCKET_URI/FILE_URI",
"properties": [
{
"name": "supplier_name",
"text_values": {
"values": "Stanford Plumbing & Heating"
}
},
{
"name": "total_amount",
"float_values": {
"values": "1091.81"
}
},
{
"name": "invoice_id",
"text_values": {
"values": "invoiceid"
}
},
]
},
"requestMetadata": {
"userInfo": {
"id": "user:USER_EMAIL"
}
}
}'문서 삭제
REST
document_id별:
curl --request POST \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-Type: application/json; charset=UTF-8" -d '{
"requestMetadata":{
"userInfo":{
"id": "user:USER_EMAIL"
}
}
}' \
"https://contentwarehouse.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/documents/DOCUMENT_ID:delete"reference_id별:
curl --request POST \
--header "Authorization: Bearer $(gcloud auth print-access-token)" \
--header "Content-Type: application/json; charset=UTF-8" -d '{
"requestMetadata":{
"userInfo":{
"id": "user:USER_EMAIL"
}
}
}' \
"https://contentwarehouse.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/documents/referenceId/REFERENCE_ID":delete"다음 단계
- 폴더에서 문서를 구성하는 방법을 알아보려면 폴더에서 문서 구성 을 진행하세요.