갤러리 템플릿
여러 장의 사진을 한 영역에 자동 배치하는 갤러리 바인딩의 사용법을 설명합니다.
갤러리 바인딩 종류
템플릿의 parameters.definitions에서 binding 값이 갤러리 타입인 변수가 있으면, 해당 변수에 이미지 배열을 전달합니다.
| binding 값 | 배치 방식 | 사진 수 |
|---|---|---|
collageGallery | 사진 비율을 분석해 콜라주 형태로 자동 배치 | 1~9장 |
rowGallery | 사진을 행 단위로 자동 배치 | 1장 이상 |
갤러리 템플릿 parameters 예시 (6c2HU8tipz1l)
{
"definitions": {
"monthNum": {
"binding": "text",
"type": "string",
"required": true,
"description": "월 번호 2자리 (예: 04)"
},
"dayNum": {
"binding": "text",
"type": "string",
"required": true,
"description": "일 번호 2자리 (예: 25)"
},
"collagePhotos": {
"binding": "collageGallery",
"type": "array",
"itemType": "file",
"minItems": 1,
"maxItems": 9,
"required": true,
"description": "콜라주 갤러리 사진들"
}
}
}이미지 전달 방법
갤러리 변수에 이미지를 전달할 때는 parameters JSON의 해당 변수에 배열로 값을 지정합니다. 배열 내 각 항목은 파일 업로드("$upload"), URL, 또는 서버에 이미 업로드된 파일명을 혼합 사용할 수 있습니다.
파일 업로드 방식
갤러리 변수명과 동일한 필드명으로 여러 파일을 전송합니다. parameters에서는 "$upload"를 순서대로 나열합니다.
URL 방식
parameters의 배열에 이미지 URL을 직접 지정합니다.
갤러리 변수의 추가 속성
| 속성 | 타입 | 설명 |
|---|---|---|
itemType | string | 배열 항목 타입 (file) |
minItems | int | 최소 사진 수 |
maxItems | int | 최대 사진 수 |
collageGallery — 파일 업로드
curl -X POST 'https://api-sandbox.sweetbook.com/v1/books/{bookUid}/contents?breakBefore=page' \
-H 'Authorization: Bearer {YOUR_API_KEY}' \
-F 'templateUid=6c2HU8tipz1l' \
-F 'collagePhotos=@photo1.jpg;type=image/jpeg' \
-F 'collagePhotos=@photo2.jpg;type=image/jpeg' \
-F 'collagePhotos=@photo3.jpg;type=image/jpeg' \
-F 'parameters={"monthNum":"04","dayNum":"25","collagePhotos":["$upload","$upload","$upload"]}'collageGallery — URL 전달
curl -X POST 'https://api-sandbox.sweetbook.com/v1/books/{bookUid}/contents?breakBefore=page' \
-H 'Authorization: Bearer {YOUR_API_KEY}' \
-F 'templateUid=6c2HU8tipz1l' \
-F 'parameters={"monthNum":"04","dayNum":"25","collagePhotos":["https://example.com/1.jpg","https://example.com/2.jpg","https://example.com/3.jpg"]}'rowGallery — 파일 업로드
curl -X POST 'https://api-sandbox.sweetbook.com/v1/books/{bookUid}/contents?breakBefore=page' \
-H 'Authorization: Bearer {YOUR_API_KEY}' \
-F 'templateUid=1vuzMfUnCkXS' \
-F 'photos=@photo1.jpg;type=image/jpeg' \
-F 'photos=@photo2.jpg;type=image/jpeg' \
-F 'photos=@photo3.jpg;type=image/jpeg' \
-F 'parameters={"monthYearLabel":"2026 APRIL","photos":["$upload","$upload","$upload"]}'rowGallery — URL 전달
curl -X POST 'https://api-sandbox.sweetbook.com/v1/books/{bookUid}/contents?breakBefore=page' \
-H 'Authorization: Bearer {YOUR_API_KEY}' \
-F 'templateUid=1vuzMfUnCkXS' \
-F 'parameters={"monthYearLabel":"2026 APRIL","photos":["https://example.com/1.jpg","https://example.com/2.jpg","https://example.com/3.jpg"]}'