시작하기
이 플러그인의 설치 단계와 전체 마크다운 가이드가 포함된 설정 지시를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-file`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/file/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
설치
설치bun add @capgo/capacitor-filebunx cap sync수입
수입import { CapacitorFile } from '@capgo/capacitor-file';API 개요
API 개요requestFileSystem
파일 시스템 요청파일 시스템을 요청합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.requestFileSystem({} as RequestFileSystemOptions);resolveLocalFileSystemURL
resolveLocalFileSystemURL 섹션파일 URL을 엔트리로 해결합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.resolveLocalFileSystemURL({} as ResolveURLOptions);getFile
getFile 섹션파일 엔트리를 가져옵니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getFile({} as GetFileOptions);getDirectory
getDirectory 섹션디렉토리 엔트리를 가져옵니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getDirectory({} as GetDirectoryOptions);readFile
readFile 섹션파일을 텍스트 또는 base64로 읽습니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.readFile({} as ReadFileOptions);readAsDataURL
readAsDataURL 섹션데이터 URL (base64 MIME 타입 접두사)로 파일을 읽습니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.readAsDataURL({} as ReadFileOptions);writeFile
파일에 데이터 쓰기 섹션파일에 데이터를 쓰세요.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.writeFile({} as WriteFileOptions);appendFile
파일에 데이터 추가 섹션파일에 데이터를 추가하세요.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.appendFile({} as WriteFileOptions);deleteFile
파일 삭제 섹션파일을 삭제하세요.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.deleteFile({} as DeleteFileOptions);mkdir
mkdir 섹션폴더를 생성합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.mkdir({} as MkdirOptions);rmdir
rmdir 섹션폴더를 삭제합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rmdir({} as DeleteDirectoryOptions);readdir
readdir 섹션폴더 내용을 읽습니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.readdir({} as ReaddirOptions);stat
stat 섹션파일 또는 폴더의 메타데이터를 가져옵니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.stat({} as StatOptions);getMetadata
__CAPGO_KEEP_0__파일 또는 디렉토리의 메타데이터에 대한 정보를 가져옵니다. stat()의 별칭입니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getMetadata({} as StatOptions);rename
__CAPGO_KEEP_0__파일 또는 디렉토리를 이름을 변경하거나 이동합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rename({} as RenameOptions);move
__CAPGO_KEEP_0__파일 또는 디렉토리를 이동합니다. rename()의 별칭입니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.move({} as RenameOptions);copy
__CAPGO_KEEP_0__파일 또는 디렉토리를 복사합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.copy({} as CopyOptions);exists
exists 항목파일 또는 디렉토리가 존재하는지 확인합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.exists({} as ExistsOptions);getUri
getUri 항목파일의 URI를 가져옵니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getUri({} as GetUriOptions);truncate
truncate 항목파일을 지정된 크기로 잘라냅니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.truncate({} as TruncateOptions);getDirectories
getDirectories 항목모든 파일 시스템 디렉토리를 가져옵니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getDirectories();getFreeDiskSpace
getFreeDiskSpace바이트 단위의 사용 가능한 디스크 공간을 가져옵니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.getFreeDiskSpace();checkPermissions
checkPermissions파일 연산에 대한 현재 권한 상태를 확인합니다. 안드로이드에서는 외부 저장소 권한을 확인합니다. iOS 및 웹에서는 특별한 권한이 필요하지 않기 때문에 항상 '허용'을 반환합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.checkPermissions();requestPermissions
requestPermissions파일 연산에 대한 권한을 요청합니다. 안드로이드에서는 앱의 개인 디렉토리 외부의 파일에 접근하기 위해 필요한 외부 저장소 권한을 요청합니다. iOS 및 웹에서는 특별한 권한이 필요하지 않기 때문에 항상 '허용'을 반환합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.requestPermissions();타입 참조
타입 참조RequestFileSystemOptions
RequestFileSystemOptions파일 시스템 요청 옵션.
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;}FileSystem
파일 시스템파일 시스템을 나타낸다.
export interface FileSystem { /** The name of the file system */ name: string; /** The root directory of the file system */ root: DirectoryEntry;}ResolveURLOptions
URL을 엔트리로 해결하는 옵션.__CAPGO_KEEP_0__
export interface ResolveURLOptions { /** The URL to resolve (file:// or cdvfile://) */ url: string;}Entry
__CAPGO_KEEP_0__URL을 엔트리로 해결하는 옵션.
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;}GetFileOptions
파일 또는 디렉토리 엔트리.__CAPGO_KEEP_0__
export interface GetFileOptions { /** Path to the file */ path: string; /** Base directory */ directory?: Directory; /** Options for creating the file */ options?: GetOptions;}FileEntry
__CAPGO_KEEP_1____CAPGO_KEEP_2__
export interface FileEntry extends Entry { isFile: true; isDirectory: false;}GetDirectoryOptions
__CAPGO_KEEP_3____CAPGO_KEEP_0__
export interface GetDirectoryOptions { /** Path to the directory */ path: string; /** Base directory */ directory?: Directory; /** Options for creating the directory */ options?: GetOptions;}DirectoryEntry
__CAPGO_KEEP_2____CAPGO_KEEP_0__
export interface DirectoryEntry extends Entry { isFile: false; isDirectory: true;}ReadFileOptions
__CAPGO_KEEP_1__파일을 읽는 옵션.
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;}ReadFileResult
“파일 읽기 결과” 섹션파일을 읽은 결과.
export interface ReadFileResult { /** File contents as string (text) or base64 (binary) */ data: string;}WriteFileOptions
“파일 쓰기 옵션” 섹션파일을 쓰는 옵션.
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
“파일 쓰기 결과” 섹션파일을 쓴 결과.
export interface WriteFileResult { /** The URI of the written file */ uri: string;}이 페이지는 플러그인의 src/definitions.ts. Re-run the sync when the public API changes upstream.
Getting Started에서 계속하기
Section titled “Getting Started에서 계속하기”Capacitor를 사용하는 경우 Getting Started storage 및 파일 처리를 계획하고 싶다면 Using @capgo/capacitor-file Using @capgo/capacitor-file의 native capability에 대해 @capgo/capacitor-data-storage-sqlite @capgo/capacitor-data-storage-sqlite의 implementation detail에 대해 Using @capgo/capacitor-data-storage-sqlite for the native capability in Using @capgo/capacitor-data-storage-sqlite @capgo/capacitor-file for the implementation detail in @capgo/capacitor-file, and @capgo/capacitor-uploader for the implementation detail in @capgo/capacitor-uploader.