내용으로 건너뛰기

Getting Started

GitHub

설치

설치

Capgo을 사용하여 플러그인을 설치하는 데 도움을 주는 AI-Assisted Setup을 사용할 수 있습니다. 다음 명령어를 사용하여 AI 도구에 Capgo 기능을 추가하세요.

터미널 창
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

그다음에 다음 프롬프트를 사용하세요.

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-file` plugin in my project.

만약 Manual Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래에 플랫폼에 따라 설명된 지침을 따르세요.

터미널 창
bun add @capgo/capacitor-file
bunx cap sync
import { CapacitorFile } from '@capgo/capacitor-file';

API 개요

API 개요

requestFileSystem

__CAPGO_KEEP_0__ Overview

__CAPGO_KEEP_0__ 개요

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.requestFileSystem({} as RequestFileSystemOptions);

resolveLocalFileSystemURL

__CAPGO_KEEP_0__ 개요

__CAPGO_KEEP_0__ Overview

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.resolveLocalFileSystemURL({} as ResolveURLOptions);

__CAPGO_KEEP_0__ 개요

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getFile({} as GetFileOptions);

__CAPGO_KEEP_0__ Overview

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getDirectory({} as GetDirectoryOptions);

__CAPGO_KEEP_2__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.readFile({} as ReadFileOptions);

readAsDataURL

__CAPGO_KEEP_1__

__CAPGO_KEEP_3__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.readAsDataURL({} as ReadFileOptions);

__CAPGO_KEEP_4__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.writeFile({} as WriteFileOptions);

__CAPGO_KEEP_5__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.appendFile({} as WriteFileOptions);

__CAPGO_KEEP_2__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.deleteFile({} as DeleteFileOptions);

__CAPGO_KEEP_3__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.mkdir({} as MkdirOptions);

__CAPGO_KEEP_0__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rmdir({} as DeleteDirectoryOptions);

__CAPGO_KEEP_0__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.readdir({} as ReaddirOptions);

__CAPGO_KEEP_2__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.stat({} as StatOptions);

getMetadata

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getMetadata({} as StatOptions);

__CAPGO_KEEP_3__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rename({} as RenameOptions);

__CAPGO_KEEP_4__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.move({} as RenameOptions);

__CAPGO_KEEP_2__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.copy({} as CopyOptions);

__CAPGO_KEEP_3__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.exists({} as ExistsOptions);

__CAPGO_KEEP_4__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getUri({} as GetUriOptions);

__CAPGO_KEEP_0__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.truncate({} as TruncateOptions);

__CAPGO_KEEP_0__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getDirectories();

getFreeDiskSpace

__CAPGO_KEEP_0__

__CAPGO_KEEP_1__에서 파일 작업을 위한 현재 권한 상태를 확인합니다. 안드로이드에서는 외부 저장소 권한을 확인합니다. iOS와 웹에서는 특별한 권한이 필요하지 않아 항상 '허용'을 반환합니다.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getFreeDiskSpace();

__CAPGO_KEEP_0__

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.checkPermissions();

requestPermissions

__CAPGO_KEEP_0__

__CAPGO_KEEP_1__에서 파일 작업을 위한 권한을 요청합니다. 안드로이드에서는 앱의 개인 디렉토리 외부의 파일에 접근하기 위한 외부 저장소 권한을 요청합니다. iOS와 웹에서는 특별한 권한이 필요하지 않아 항상 '허용'을 반환합니다.

import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.requestPermissions();

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

RequestFileSystemOptions

__CAPGO_KEEP_3__

__CAPGO_KEEP_4__

export interface RequestFileSystemOptions {
/** The type of file system to request */
type: FileSystemType;
/** Requested size in bytes (may not be enforced on all platforms) */
size?: number;
}

__CAPGO_KEEP_6__

export interface FileSystem {
/** The name of the file system */
name: string;
/** The root directory of the file system */
root: DirectoryEntry;
}

ResolveURLOptions

__CAPGO_KEEP_7__

__CAPGO_KEEP_8__

export interface ResolveURLOptions {
/** The URL to resolve (file:// or cdvfile://) */
url: string;
}

파일 또는 디렉토리 항목을 나타낸다.

export interface Entry {
/** True if this is a file */
isFile: boolean;
/** True if this is a directory */
isDirectory: boolean;
/** The name of the file or directory */
name: string;
/** The full path relative to the filesystem root */
fullPath: string;
/** The native file:// URI */
nativeURL: string;
}

파일을 가져올 때의 옵션.

export interface GetFileOptions {
/** Path to the file */
path: string;
/** Base directory */
directory?: Directory;
/** Options for creating the file */
options?: GetOptions;
}

파일 항목을 나타낸다.

export interface FileEntry extends Entry {
isFile: true;
isDirectory: false;
}

디렉토리를 가져올 때의 옵션.

export interface GetDirectoryOptions {
/** Path to the directory */
path: string;
/** Base directory */
directory?: Directory;
/** Options for creating the directory */
options?: GetOptions;
}

디렉토리 엔트리를 나타냅니다.

export interface DirectoryEntry extends Entry {
isFile: false;
isDirectory: true;
}

파일을 읽기 위한 옵션입니다.

export interface ReadFileOptions {
/** Path to the file */
path: string;
/** Base directory */
directory?: Directory;
/** Encoding for text files (omit for binary/base64) */
encoding?: Encoding;
/** Byte offset to start reading from (default: 0) */
offset?: number;
/** Number of bytes to read (default: read to end of file) */
length?: number;
}

파일을 읽은 결과입니다.

export interface ReadFileResult {
/** File contents as string (text) or base64 (binary) */
data: string;
}

파일을 쓰기 위한 옵션입니다.

export interface WriteFileOptions {
/** Path to the file */
path: string;
/** Base directory */
directory?: Directory;
/** Data to write (string for text, base64 for binary) */
data: string;
/** Encoding for text files */
encoding?: Encoding;
/** If true, append to existing file instead of overwriting */
append?: boolean;
/** Create intermediate directories if they don't exist */
recursive?: boolean;
/** Byte position to start writing at (for random access writes). If not specified, writes from beginning or appends based on 'append' flag */
position?: number;
}

WriteFileResult

WriteFileResult

파일을 쓰기 위한 결과

export interface WriteFileResult {
/** The URI of the written file */
uri: string;
}

이 페이지는 플러그인의 src/definitions.ts업스트림에서 pubic API이 변경되었을 때 다시 싱크를 실행하세요.

storage와 file handling을 계획하고 있다면 Getting Started Getting Started를 사용하고 있다면 @capgo/capacitor-파일을 사용하여 for the native capability in @capgo/capacitor-파일을 사용하여 @capgo/capacitor-sqlite 데이터 저장소 for the implementation detail in @capgo/capacitor-sqlite 데이터 저장소, Using @capgo/capacitor-sqlite 데이터 저장소 for the native capability in Using @capgo/capacitor-sqlite 데이터 저장소, @capgo/capacitor-파일 for the implementation detail in @capgo/capacitor-파일, and @capgo/capacitor-업로더 for the implementation detail in @capgo/capacitor-업로더.