구조화된 데이터 파일 업로드

Display & Video 360 API를 사용하여 구조화된 데이터 파일을 업로드하면 YouTube 리소스를 비롯한 리소스를 프로그래매틱 방식으로 일괄 생성하고 업데이트할 수 있습니다. 이 페이지에서는 API를 사용하여 구조화된 데이터 파일을 준비하고 업로드하는 방법을 설명합니다.

Google Cloud 프로젝트는 하루에 광고주 ID당 30개의 구조화된 데이터 파일만 업로드할 수 있습니다.

업로드할 구조화된 데이터 파일 준비

업로드된 구조화된 데이터 파일은 최근에 다운로드한 구조화된 데이터 파일의 수정된 버전이어야 하며, 파일 형식과 광고주가 동일해야 합니다. 다음과 같이 업데이트하여 다운로드한 구조화된 데이터 파일을 업로드할 수 있도록 준비합니다.

  • 만들려는 새 리소스의 항목을 추가합니다.
  • 업데이트할 리소스의 기존 항목을 업데이트합니다.
  • 파일 크기를 줄이고 처리 시간을 단축하며 의도치 않은 업데이트 가능성을 없애기 위해 새로 추가되거나 업데이트되지 않은 항목을 삭제합니다.

파일을 업로드하기 전에 다음을 확인하세요.

  • 파일은 CSV 파일입니다.
  • 파일의 모든 항목은 동일한 상위 광고주의 리소스에 해당합니다.

파일 업로드

advertisers.sdfuploadtasks.upload 메서드를 사용하여 구조화된 데이터 파일을 업로드합니다. 이 요청은 SDF 업로드 작업 Operation을 만듭니다. 이 장기 실행 작업은 업로드된 파일을 처리하고, 파일 콘텐츠를 기반으로 리소스를 생성 및 업데이트하며, 성공한 업데이트와 실패한 업데이트를 나열하는 결과 파일을 생성합니다.

구조화된 데이터 파일을 업로드하고 결과 Operation를 가져오는 방법은 다음과 같습니다.

# Import the object used as the media body for the upload request.
from apiclient.http import MediaFileUpload

# Provide the parent advertiser ID for the resources in the SDF.
# The ID value must be a str and not an int.
advertiser_id = advertiser-id

# Provide the filename and local path to the media file.
sdf_filename = sdf-filename
sdf_path = sdf-path

# Create the request body.
body = {
  'filename': sdf_filename,
  'advertiserId': advertiser_id
}

# Create the upload object and use a default MIME type if not identified.
media = MediaFileUpload(sdf_path)
if not media.mimetype():
  media = MediaFileUpload(sdf_filename,'application/octet-stream')

# Upload the structured data file.
upload_response = service.advertisers().sdfuploadtasks().upload(
  advertiserId=advertiser_id,
  body=body,
  media_body=media
).execute()

# Print resulting Operation name.
print(f'SDF was successfully uploaded. Operation {upload_response["name"]} was '
       'created to process the uploaded file.')