시작하기
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함한 설정 지시를 복사하세요.
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.
설치
설치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-filebunx cap syncImport
Importimport { CapacitorFile } from '@capgo/capacitor-file';API 개요
API 개요requestFileSystem
파일 시스템 요청파일 시스템 요청
import { CapacitorFile, FileSystemType } from '@capgo/capacitor-file';
const result = await CapacitorFile.requestFileSystem({ type: FileSystemType.TEMPORARY });console.log(result);resolveLocalFileSystemURL
URL을 엔트리로 변환URL을 엔트리로 변환
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.resolveLocalFileSystemURL({ url: 'https://example.com' });console.log(result);getFile
파일 가져오기파일 엔트리 가져오기.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getFile({ path: 'path/to/file' });console.log(result);getDirectory
getDirectory디렉토리 엔트리 가져오기.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getDirectory({ path: 'path/to/file' });console.log(result);readFile
readFile텍스트 또는 base64로 파일 읽기.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.readFile({ path: 'path/to/file' });console.log(result);readAsDataURL
readAsDataURLbase64와 MIME 타입 접두사(prefix)가 포함된 데이터 URL로 파일 읽기.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.readAsDataURL({ path: 'path/to/file' });console.log(result);writeFile
writeFile파일에 데이터를 쓰세요.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.writeFile({ path: 'path/to/file', data: 'data',});console.log(result);appendFile
appendFile파일에 데이터를 추가하세요.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.appendFile({ path: 'path/to/file', data: 'data',});console.log(result);deleteFile
deleteFile파일을 삭제하세요.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.deleteFile({ path: 'path/to/file' });mkdir
mkdir디렉토리를 생성하세요.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.mkdir({ path: 'path/to/file' });rmdir
rmdir디렉터리 삭제
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rmdir({ path: 'path/to/file' });readdir
‘readdir’ 섹션디렉터리 내용 읽기
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.readdir({ path: 'path/to/file' });console.log(result);stat
‘stat’ 섹션파일 또는 디렉터리의 메타데이터 가져오기
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.stat({ path: 'path/to/file' });console.log(result);getMetadata
‘getMetadata’ 섹션파일 또는 디렉터리의 메타데이터 가져오기. stat()의 별칭
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getMetadata({ path: 'path/to/file' });console.log(result);rename
‘rename’ 섹션파일 또는 디렉토리를 이름 바꾸거나 위치 이동.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.rename({ from: 'from', to: 'to',});move
이동파일 또는 디렉토리 이동. rename()의 별칭.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.move({ from: 'from', to: 'to',});copy
이동파일 또는 디렉토리 복사.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.copy({ from: 'from', to: 'to',});console.log(result);exists
복사파일 또는 디렉토리가 존재하는지 확인.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.exists({ path: 'path/to/file' });console.log(result);getUri
URI 가져오기파일 URI를 가져오세요.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getUri({ path: 'path/to/file' });console.log(result);truncate
파일을 지정된 크기로 잘라내세요.파일 시스템의 모든 디렉토리를 가져오세요.
import { CapacitorFile } from '@capgo/capacitor-file';
await CapacitorFile.truncate({ path: 'path/to/file' });getDirectories
디스크의 사용 가능한 공간을 가져오세요.파일의 권한을 확인하세요.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getDirectories();console.log(result);getFreeDiskSpace
truncategetDirectories
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.getFreeDiskSpace();console.log(result);checkPermissions
getFreeDiskSpace파일 연산에 대한 현재 권한 상태를 확인하세요. 안드로이드에서는 외부 저장소 권한을 확인합니다. iOS와 웹에서는 특별한 권한이 필요하지 않기 때문에 항상 '허용'을 반환합니다.
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.checkPermissions();console.log(result);requestPermissions
권한 요청권한 요청
import { CapacitorFile } from '@capgo/capacitor-file';
const result = await CapacitorFile.requestPermissions();console.log(result);타입 참조
타입 참조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 옵션을 해결하는 방법URL을 엔트리로 해결하는 옵션입니다.
export interface ResolveURLOptions { /** The URL to resolve (file:// or cdvfile://) */ url: string;}Entry
엔트리파일 또는 디렉토리 엔트리를 나타냅니다.
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
파일을 가져오는 방법파일 엔트리를 나타냅니다.
export interface GetFileOptions { /** Path to the file */ path: string; /** Base directory */ directory?: Directory; /** Options for creating the file */ options?: GetOptions;}FileEntry
파일 엔트리파일
export interface FileEntry extends Entry { isFile: true; isDirectory: false;}GetDirectoryOptions
GetDirectoryOptions 섹션디렉토리 가져오기 옵션
export interface GetDirectoryOptions { /** Path to the directory */ path: string; /** Base directory */ directory?: Directory; /** Options for creating the directory */ options?: GetOptions;}DirectoryEntry
DirectoryEntry 섹션디렉토리 항목을 나타냅니다.
export interface DirectoryEntry extends Entry { isFile: false; isDirectory: true;}ReadFileOptions
ReadFileOptions 섹션파일 읽기 옵션
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
ReadFileResult 섹션파일 읽기 결과
export interface ReadFileResult { /** File contents as string (text) or base64 (binary) */ data: string;}WriteFileOptions
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
WriteFileResult 섹션파일 쓰기 결과
export interface WriteFileResult { /** The URI of the written file */ uri: string;}실질적인 출처
실질적인 출처 섹션이 페이지는 플러그인의 src/definitions.ts공개 API이 업스트림에서 변경될 때 다시 싱크를 실행하세요.
Getting Started에서 계속하세요
Getting Started만약에 Getting Started 파일 및 저장소 처리를 계획하고 싶다면 @capgo/capacitor-파일 사용 Using @capgo/capacitor-file Using @capgo/capacitor-data-storage-sqlite Using @capgo/capacitor-data-storage-sqlite @capgo/capacitor-SQLite 데이터 저장소 사용 Using @capgo/capacitor-file Using @capgo/capacitor-file for the @capgo/capacitor-file implementation detail in @capgo/capacitor-업로더 @capgo/capacitor-업로더 구현 세부 사항에 대해.