Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

첨부 파일 메타데이터 조회(Get Attachment) (V1)

첨부 파일의 메타데이터를 조회합니다. 필수 경로 매개변수 attachmentRid는 첨부 파일 RID 문자열입니다. 쿼리 매개변수와 요청 본문은 없습니다.

응답

Attachment는 다음 필드를 모두 포함합니다.

필드자료형의미
ridstring첨부 파일 RID
filenamestring파일 이름
sizeBytesstring, long바이트 단위 크기
mediaTypestring파일 미디어 유형. 예: image/jpeg, application/pdf

파일 바이트는 Get Attachment Content로 조회합니다. 첨부 파일의 권한과 정리 조건은 첨부 파일 기본 개념을 따릅니다.

HTTP 요청

GET /api/v1/attachments/{attachmentRid}

작업 식별자는 v1.getAttachment입니다. Authorization: Bearer <접근 토큰> 헤더로 인증합니다. OAuth 클라이언트에는 api:ontologies-read 권한 범위가 필요합니다.

JSON 응답 예시

가상 첨부 파일 My Image.jpeg의 메타데이터 응답 예시입니다.

{
  "rid": "ri.attachments.main.attachment.bb32154e-e043-4b00-9461-93136ca96b6f",
  "filename": "My Image.jpeg",
  "sizeBytes": "393469",
  "mediaType": "image/jpeg"
}

오류

실패 응답은 공통 API 오류의 형식으로 처리합니다.

요청 예제

FOUNDRY_HOST에는 https://를 제외한 Foundry 호스트를, FOUNDRY_TOKEN에는 유효한 토큰을 환경 변수로 제공합니다. 아래 식별자와 입력값은 예시이므로 실제 요청 대상에 맞게 지정합니다.

cURL

curl \
	-H "Authorization: Bearer ${FOUNDRY_TOKEN}" \
	"https://${FOUNDRY_HOST}/api/v1/attachments/ri.attachments.main.attachment.bb32154e-e043-4b00-9461-93136ca96b6f"

Python

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

import os
import requests

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

response = requests.get('https://{}/api/v1/attachments/ri.attachments.main.attachment.bb32154e-e043-4b00-9461-93136ca96b6f'.format(HOSTNAME), headers=headers)
print(response)

Java

Apache HttpClient 4.5 API와 try-with-resources를 사용하는 예제입니다. 클래스 이름에 맞는 GetAttachmentExample.java 파일에서 사용합니다.

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 GetAttachmentExample {
    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/v1/attachments/ri.attachments.main.attachment.bb32154e-e043-4b00-9461-93136ca96b6f");
            request.addHeader("authorization", String.format("Bearer %s", TOKEN));
            try (CloseableHttpResponse response = httpClient.execute(request)) {
                System.out.println(response);
            }
        }
    }
}

JavaScript

fetch를 제공하는 Node.js 환경에서 사용합니다. 서비스 사용자 토큰을 브라우저로 전달하지 않습니다.

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

fetch(`https://${HOSTNAME}/api/v1/attachments/ri.attachments.main.attachment.bb32154e-e043-4b00-9461-93136ca96b6f`, {
    method: 'GET',
    headers: {
        'Authorization': `Bearer ${TOKEN}`,
    }
}).then((response) => {
    console.log(response)
});

PowerShell

$TOKEN = $env:FOUNDRY_TOKEN
$HOSTNAME = $env:FOUNDRY_HOST

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

$response = Invoke-WebRequest -Uri "https://$HOSTNAME/api/v1/attachments/ri.attachments.main.attachment.bb32154e-e043-4b00-9461-93136ca96b6f" `
	-Headers $headers

$response.content