> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/common/file-storage/file.md). Agents can also search and read this documentation through its [MCP server](https://developers-apps-in-toss.toss.im/~gitbook/mcp).

# 파일 저장

### 파일 저장하기 <a href="#save-file" id="save-file"></a>

**SDK 함수:** `saveBase64Data`

`saveBase64Data` 함수는 문자열로 인코딩된 Base64 데이터를 지정한 파일 이름과 MIME 타입으로 사용자 기기에 저장해요. 이미지, 텍스트, PDF 등 다양한 형식의 데이터를 저장할 수 있어요.

**시그니처**

```typescript
function saveBase64Data(params: SaveBase64DataParams): Promise<void>;
```

**파라미터**

* **params** · 필수 · `SaveBase64DataParams`

  저장할 데이터와 파일 정보를 담은 객체예요.

  * **params.data** · 필수 · `string`

    Base64 형식으로 인코딩된 데이터 문자열이에요.
  * **params.fileName** · 필수 · `string`

    저장할 파일 이름이에요. 확장자도 같이 붙여줘야해요. 예를 들어, 'example.png'로 저장할 수 있어요.
  * **params.mimeType** · 필수 · `string`

    저장할 파일의 MIME 타입이에요. 예를 들어 'image/png' 로 지정하면 이미지, 'application/pdf'는 PDF 파일이에요. 자세한 내용은 [MIME 문서](https://developer.mozilla.org/ko/docs/Web/HTTP/Guides/MIME_types)를 참고해주세요.

**예제**

**Base64 이미지 데이터를 사용자 기기에 저장하기**

{% tabs %}
{% tab title="js" %}

```js
import { saveBase64Data } from '@apps-in-toss/web-framework';

async function handleSaveBase64Data() {
  try {
    await saveBase64Data({
      data: 'iVBORw0KGgo...',
      fileName: 'some-photo.png',
      mimeType: 'image/png',
    });
    console.log('데이터 저장 성공');
  } catch (error) {
    console.error('데이터 저장에 실패했어요:', error);
  }
}
```

{% endtab %}

{% tab title="React" %}

```tsx
import { saveBase64Data } from '@apps-in-toss/web-framework';
import { Button } from '@toss/tds-mobile';

function SaveButton() {
  const handleSave = async () => {
    try {
      await saveBase64Data({
        data: 'iVBORw0KGgo...',
        fileName: 'some-photo.png',
        mimeType: 'image/png',
      });
    } catch (error) {
      console.error('데이터 저장에 실패했어요:', error);
    }
  };

  return <Button onClick={handleSave}>저장</Button>;
}
```

{% endtab %}

{% tab title="React Native" %}

```tsx
import { saveBase64Data } from '@apps-in-toss/framework';
import { Button } from '@toss/tds-react-native';

function SaveButton() {
  const handleSave = async () => {
    try {
      await saveBase64Data({
        data: 'iVBORw0KGgo...',
        fileName: 'some-photo.png',
        mimeType: 'image/png',
      });
    } catch (error) {
      console.error('데이터 저장에 실패했어요:', error);
    }
  };

  return <Button onPress={handleSave}>저장</Button>;
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers-apps-in-toss.toss.im/documentation/common/file-storage/file.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
