내용으로 건너뛰기

Getting Started

GitHub

우리 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';

__CAPGO_KEEP_0__을 요청합니다.

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

resolveLocalFileSystemURL

__CAPGO_KEEP_2__ 섹션

__CAPGO_KEEP_0__ URL을 엔트리로 해결합니다.

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__ 디렉토리를 가져옵니다.

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

파일을 텍스트 또는 base64로 읽습니다.

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

readAsDataURL

readAsDataURL

파일을 base64로 읽습니다.

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

writeFile

writeFile

파일에 데이터를 씁니다.

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

appendFile

appendFile

파일에 데이터를 추가합니다.

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

deleteFile

deleteFile

__CAPGO_KEEP_0__

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_4__

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

__CAPGO_KEEP_5__

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

파일 또는 디렉토리의 메타데이터를 가져옵니다.

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

파일 또는 디렉토리의 메타데이터를 가져옵니다. stat()의 별칭입니다.

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

파일 또는 디렉토리를 이름을 바꾸거나 이동합니다.

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

파일 또는 디렉토리를 이동합니다. rename()의 별칭입니다.

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

__CAPGO_KEEP_0__

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

__CAPGO_KEEP_1__

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

__CAPGO_KEEP_2__

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

__CAPGO_KEEP_3__

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

getDirectories

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__ 디렉토리 목록을 모두 가져옵니다.

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

getFreeDiskSpace

getFreeDiskSpace 섹션

__CAPGO_KEEP_0__ 바이트 단위의 사용 가능한 디스크 공간을 가져옵니다.

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

checkPermissions

checkPermissions 섹션

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

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

requestPermissions

requestPermissions 섹션

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

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

Type Reference

Type Reference 섹션

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;
}

파일 시스템을 나타냅니다.

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

ResolveURLOptions

ResolveURLOptions 섹션

URL을 엔트리로 변환하는 옵션입니다.

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;
}

파일을 쓴 결과입니다.

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

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

이 플러그인을 사용 중이라면 Getting Started 저장소와 파일 처리를 계획하고 싶다면 Using @capgo/capacitor-file Using @capgo/capacitor-file @capgo/capacitor-data-storage-sqlite capgo의 구현 세부 사항은 @capgo/capacitor-data-storage-sqlite에서 확인할 수 있습니다. @capgo/capacitor-data-storage-sqlite을 사용합니다. capgo의 원시 기능은 Using @capgo/capacitor-data-storage-sqlite에서 확인할 수 있습니다. @capgo/capacitor-file capgo의 구현 세부 사항은 @capgo/capacitor-file에서 확인할 수 있습니다. @capgo/capacitor-uploader capgo의 구현 세부 사항은 @capgo/capacitor-uploader에서 확인할 수 있습니다.