---
title: "파일 교체"
slug: "rag-replace-file"
updated: 2026-04-23T08:55:35Z
published: 2026-04-23T09:02:17Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://api.ncloud-docs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 파일 교체

<p class="platform-info type-vpc">VPC 환경에서 이용 가능합니다.</p>

기존에 업로드한 파일을 새로운 파일로 교체합니다.

## 요청<a name="요청"></a>
요청 형식을 설명합니다. 요청 형식은 다음과 같습니다.

| 메서드 | URI |
| --- | --- |
| PUT | /api/v1/svc/{serviceId}/file/{fileId} |

### 요청 헤더<a name="요청헤더"></a>
RAG API 에서 공통으로 사용하는 헤더에 대한 정보는 [RAG 요청 헤더](/docs/rag-overview#요청헤더)를 참조해 주십시오.

### 요청 경로 파라미터<a name="요청경로파라미터"></a>
요청 경로 파라미터에 대한 설명은 다음과 같습니다.

| 필드 | 타입 | 필수 여부 | 설명 |
| --- | --- | --- | --- |
| `serviceId` | String | Required | 서비스의 고유 식별자 |
| `fileId` | String | Required | 파일의 고유 식별자 |

### 요청 쿼리 파라미터<a name="요청쿼리파라미터"></a>
요청 쿼리 파라미터에 대한 설명은 다음과 같습니다.

| 필드 | 타입 | 필수 여부 | 설명 |
| --- | --- | --- | --- |
| `background` | Boolean | Optional | 텍스트 추출을 백그라운드에서 처리할지 여부<ul><li>`true` \| `false` (기본값)<ul><li>`true`:  파일을 업로드하면 즉시 응답을 반환하고, 텍스트 추출은 백그라운드에서 비동기 처리</li><li>`false`: 텍스트 추출까지 마친 후 응답 반환 (동기 처리)</li></ul></li></ul>|

### 요청 바디<a name="요청바디"></a>
요청 바디에 대한 설명은 다음과 같습니다.

| 필드 | 타입 | 필수 여부 | 설명 |
| --- | --- | --- | --- |
| `file` | 파일 | Required | 업로드할 파일 (최대 1개)<ul><li>지원 형식<ul><li>이미지: JPG, PNG, TIFF</li><li>문서: PDF, PPTX, DOCX, HWP, HWPX, TXT</li><li>데이터 파일: MD, JSON, XML</li></ul><li>파일 크기: 최대 100MB</li></ul>|
| `document` | 문서 | Optional | 업로드할 파일의 메타데이터를 포함한 문서<ul><li>문서추가/교체 와 동일한 형식의 object를 json 문자열로 전달</li><li>document.body는 파일에서 추출한 문자열로 대체</li><li>[요청 바디](/docs/rag-add-doc#요청바디) 참조</li></ul> |
 
 
### 요청 예시<a name="요청예시"></a>
요청 예시는 다음과 같습니다.

```shell
curl --location --request PUT 'https://kr-pub-gateway.rag.naverncp.com/api/v1/svc/{serviceId}/file/12345?background=true' \
--header 'Authorization: Bearer {apiKey}' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@"filePath"' \
--form 'document={"id":"string","orgid":"string","title":"string","file_name":"string","body":"","url":"string","created_at":"2025-07-25T06:43:53.863Z","extra":{"additionalProp1":{}}}'
```

## 응답<a name="응답"></a>
응답 형식을 설명합니다.

### 응답 바디<a name="응답바디"></a>
응답 바디에 대한 설명은 다음과 같습니다.

| 필드 | 타입 | 필수 여부 | 설명 |
| --- | --- | --- | --- |
| `status` | Object | - | API 처리 결과 |
| `status.code` | Integer | - | [API 응답 상태 코드](/docs/rag-overview#응답상태코드) |
| `status.message` | String | - | [API 응답 상태 메시지](/docs/rag-overview#응답상태코드) |
| `result` | Object | - | 파일 처리 결과 |
| `result.inserted` | Array | - | 생성된 파일 ID (항상 `null`) |
| `result.deleted` | Array | - | 삭제된 파일 ID (항상 `null`) |
| `result.updated` | Array | - | 수정된 파일 ID |

### 응답 상태 코드<a name="응답상태코드"></a>
RAG API에서 공통으로 사용하는 응답 상태 코드에 대한 정보는 [RAG 응답 상태 코드](/docs/rag-overview#응답상태코드)를 참조해 주십시오.

### 응답 예시<a name="응답예시"></a>
응답 예시는 다음과 같습니다.

```json
{
    "status": {
        "code": 200,
        "message": ""
    },
    "result": {
        "inserted": null,
        "deleted": null,
        "updated": [
            "12345"
        ]
    }
}
```
