Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

첨부파일 속성의 내용 조회(Get Attachment Property Content) (V2)

객체의 첨부파일 속성이 참조하는 파일 내용을 바이너리로 받습니다. 첨부파일 배열의 특정 RID를 선택하려면 RID별 내용 조회를 사용합니다.

HTTP 요청

GET /api/v2/ontologies/{ontology}/objects/{objectType}/{primaryKey}/attachments/{property}/content

작업 식별자는 v2.getAttachmentPropertyContentV2입니다. OAuth2로 호출하는 타사 애플리케이션에는 api:ontologies-read 권한 범위가 필요합니다. 각 요청에 Authorization: Bearer <접근 토큰>을 전달합니다.

경로 매개변수

이름자료형필수 여부의미와 조건예시 값
ontologystring필수온톨로지의 API 이름 또는 RID입니다. List Ontologies 또는 Ontology Manager에서 확인합니다.palantir
objectTypestring필수객체 유형의 API 이름입니다. List Object Types 또는 Ontology Manager에서 확인합니다.employee
primaryKeystring필수첨부파일을 가진 객체의 기본 키입니다.50030
propertystring필수첨부파일 속성의 API 이름입니다. Ontology Manager 또는 Get Object Type에서 확인합니다.performance

쿼리 매개변수

이름자료형필수 여부의미와 조건예시 값
sdkPackageRidstring선택생성된 SDK 패키지의 RID입니다.
sdkVersionstring선택생성된 SDK의 버전입니다.
branchstring선택읽을 Foundry 브랜치입니다. 생략하면 기본 브랜치를 사용합니다.ri.branch..branch.d827184f-ee0e-4351-8b70-efbe51e07252

요청 본문

요청 본문을 사용하지 않습니다.

응답

응답은 파일의 바이너리 내용입니다. 텍스트나 JSON으로 변환하지 않고 저장합니다.

개별 오류

오류 응답 처리는 공통 API 오류 계약을 따릅니다.

요청 예제

FOUNDRY_HOST에는 https://를 제외한 Foundry 호스트를, FOUNDRY_TOKEN에는 유효한 토큰을 제공합니다.

온톨로지와 객체 유형의 API 이름, 객체의 기본 키, 속성 API 이름과 브랜치는 실제 조회 대상에 맞게 바꿉니다. 기본 브랜치를 사용할 때는 branch를 생략합니다.

MEDIA_OUTPUT_FILE은 저장할 로컬 파일 경로입니다. 기존 파일을 덮어쓰며 본문을 텍스트로 변환하지 않고 바이트로 기록합니다.

cURL

curl --fail --output "${MEDIA_OUTPUT_FILE}" \
	-H "Authorization: Bearer ${FOUNDRY_TOKEN}" \
	"https://${FOUNDRY_HOST}/api/v2/ontologies/palantir/objects/employee/50030/attachments/performance/content?branch=ri.branch..branch.d827184f-ee0e-4351-8b70-efbe51e07252"

Python

Requests 라이브러리가 설치된 환경에서 사용합니다.

import os
import requests

HOSTNAME = os.environ["FOUNDRY_HOST"]
TOKEN = os.environ["FOUNDRY_TOKEN"]
headers = {
    "authorization": "Bearer {}".format(TOKEN)
}

with requests.get('https://{}/api/v2/ontologies/palantir/objects/employee/50030/attachments/performance/content?branch=ri.branch..branch.d827184f-ee0e-4351-8b70-efbe51e07252'.format(HOSTNAME), headers=headers, stream=True) as response:
    response.raise_for_status()
    with open(os.environ["MEDIA_OUTPUT_FILE"], "wb") as output:
        for chunk in response.iter_content(chunk_size=1024 * 1024):
            output.write(chunk)

Java

Apache HttpClient 4.5 API를 사용하는 GetAttachmentPropertyContentV2Example.java 예제입니다.

import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;

public class GetAttachmentPropertyContentV2Example {
    public static void main(String[] args) throws Exception {
        String HOSTNAME = System.getenv("FOUNDRY_HOST");
        String TOKEN = System.getenv("FOUNDRY_TOKEN");

        try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
            HttpGet request = new HttpGet("https://" + HOSTNAME + "/api/v2/ontologies/palantir/objects/employee/50030/attachments/performance/content?branch=ri.branch..branch.d827184f-ee0e-4351-8b70-efbe51e07252");
            request.addHeader("authorization", String.format("Bearer %s", TOKEN));
            try (CloseableHttpResponse response = httpClient.execute(request)) {
                int status = response.getStatusLine().getStatusCode();
                if (status < 200 || status >= 300) throw new IOException("HTTP " + status);
                try (OutputStream output = Files.newOutputStream(Paths.get(System.getenv("MEDIA_OUTPUT_FILE")))) {
                    response.getEntity().writeTo(output);
                }
            }
        }
    }
}

JavaScript

fetch를 제공하는 Node.js 환경에서 사용합니다. import가 있는 예제는 ES 모듈(.mjs)로 실행합니다. 서비스 사용자 토큰을 브라우저로 전달하지 않습니다.

import { createWriteStream } from "node:fs";
import { Readable } from "node:stream";
import { pipeline } from "node:stream/promises";

const HOSTNAME = process.env.FOUNDRY_HOST;
const TOKEN = process.env.FOUNDRY_TOKEN;

const response = await fetch(`https://${HOSTNAME}/api/v2/ontologies/palantir/objects/employee/50030/attachments/performance/content?branch=ri.branch..branch.d827184f-ee0e-4351-8b70-efbe51e07252`, {
    method: 'GET',
    headers: {
        'Authorization': `Bearer ${TOKEN}`,
    }
 });
if (!response.ok) {
    await response.body?.cancel();
    throw new Error(`HTTP ${response.status}`);
}
await pipeline(Readable.fromWeb(response.body), createWriteStream(process.env.MEDIA_OUTPUT_FILE));

PowerShell

스크립트 오류가 발생하면 중단하도록 ErrorActionPreference를 설정합니다.

$ErrorActionPreference = 'Stop'
$TOKEN = $env:FOUNDRY_TOKEN
$HOSTNAME = $env:FOUNDRY_HOST

$headers = @{
    "authorization" = "Bearer $TOKEN"
}

Invoke-WebRequest -Uri "https://$HOSTNAME/api/v2/ontologies/palantir/objects/employee/50030/attachments/performance/content?branch=ri.branch..branch.d827184f-ee0e-4351-8b70-efbe51e07252" `
	-Headers $headers `
    -OutFile $env:MEDIA_OUTPUT_FILE