메뉴로 바로가기

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-zip` plugin in my project.

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

__CAPGO_KEEP_0__
bun add @capgo/capacitor-zip
bunx cap sync
import { CapacitorZip } from '@capgo/capacitor-zip';

파일이나 폴더를 압축하여 ZIP 아카이브를 생성합니다.

파일이나 폴더를 압축하여 ZIP 아카이브를 생성합니다. 아카이브는 전체 폴더 구조를 포함합니다. 소스는 폴더일 경우.

플랫폼별 참고사항:

  • iOS: 암호 보호가 지원되지 않습니다. 암호가 제공되면 무시되고 경고가 기록됩니다.
  • Android: __CAPGO_KEEP_0__ AES-256 암호화가 제공된 비밀번호를 사용할 때 지원됩니다.
  • Web: 지원되지 않습니다. 호출 시 오류가 발생합니다.
import { CapacitorZip } from '@capgo/capacitor-zip';
// Compress a directory without password
await CapacitorZip.zip({
source: '/path/to/my-folder',
destination: '/path/to/output.zip'
});

지정된 목적지 디렉토리로 ZIP 아카이브를 압축 해제합니다.

ZIP 아카이브에서 모든 파일과 폴더를 추출하여 디렉토리 구조를 유지합니다. 목적지 디렉토리가 존재하지 않으면 생성합니다.

플랫폼별 참고 사항:

  • iOS: 표준 ZIP 아카이브를 지원합니다. 제공된 비밀번호를 사용하여 암호화된 아카이브를 추출합니다.
  • Android: 비밀번호가 제공된 AES 암호화 아카이브를 지원합니다. zip slip 취약성 보호도 제공합니다.
  • Web: 브라우저의 다운로드 폴더로 각 파일을 개별적으로 다운로드합니다. 디렉토리 구조를 생성할 수 없습니다.
import { CapacitorZip } from '@capgo/capacitor-zip';
// Extract a standard ZIP archive
await CapacitorZip.unzip({
source: '/path/to/archive.zip',
destination: '/path/to/extract-folder'
});

타입 참조

Type Reference

ZipOptions

ZipOptions

ZIP 압축 생성 옵션입니다.

export interface ZipOptions {
/**
* Path to the file or directory to compress.
*
* This can be an absolute path or a path relative to the app's working directory.
* If the source is a directory, all its contents will be recursively compressed
* while preserving the directory structure.
*
* Platform-specific notes:
* - iOS: Use file:// URLs or absolute paths. Relative paths are resolved from the app's documents directory.
* - Android: Use absolute file paths or content:// URIs for files accessible via the Android Storage Access Framework.
* - Web: Not supported.
*
* @since 7.0.0
* @example '/Users/app/Documents/my-folder'
* @example '/var/mobile/Containers/Data/Application/.../Documents/file.pdf'
* @example 'file:///storage/emulated/0/Download/document.pdf'
*/
source: string;
/**
* Path where the ZIP archive will be created.
*
* The destination path must include the .zip file extension. If the parent
* directory doesn't exist, it will be created automatically.
*
* Platform-specific notes:
* - iOS: Use file:// URLs or absolute paths. Relative paths are resolved from the app's documents directory.
* - Android: Use absolute file paths. The plugin will create any missing parent directories.
* - Web: Not supported.
*
* @since 7.0.0
* @example '/Users/app/Documents/archive.zip'
* @example '/var/mobile/Containers/Data/Application/.../Documents/backup.zip'
* @example 'file:///storage/emulated/0/Download/compressed.zip'
*/
destination: string;
/**
* Optional password for encrypting the ZIP archive.
*
* When provided, the archive will be encrypted and require this password
* to extract. Uses AES-256 encryption on Android.
*
* Platform-specific notes:
* - iOS: Password protection is NOT supported. The password will be ignored and a warning will be logged.
* - Android: Supports AES-256 encryption via zip4j library. The password must be provided during extraction.
* - Web: Not supported.
*
* @since 7.0.0
* @example 'mySecurePassword123'
*/
password?: string;
/**
* Whether to include the parent folder in the ZIP archive.
*
* When true (default), the source folder itself becomes the root directory in the archive.
* When false, only the contents of the source folder are included at the root level.
*
* This option only applies when the source is a directory. For single files, this option is ignored.
*
* @default true
* @since 8.0.5
* @example
* ```typescript
* // With includeParentFolder: true (default)
* // Source: /cache/temp/ containing [database.backup, media/]
* // ZIP contains: temp/database.backup, temp/media/
* await CapacitorZip.zip({
* source: '/cache/temp',
* destination: '/cache/backup.zip',
* includeParentFolder: true
* });
* ```
* @example
* ```typescript
* // With includeParentFolder: false
* // Source: /cache/temp/ containing [database.backup, media/]
* // ZIP contains: database.backup, media/
* await CapacitorZip.zip({
* source: '/cache/temp',
* destination: '/cache/backup.zip',
* includeParentFolder: false
* });
* ```
*/
includeParentFolder?: boolean;
}

UnzipOptions

UnzipOptions

ZIP 압축 해제 옵션입니다.

export interface UnzipOptions {
/**
* Path to the ZIP archive to extract.
*
* The source must be a valid ZIP file. If the file doesn't exist or is
* corrupted, the operation will fail with an error.
*
* Platform-specific notes:
* - iOS: Use file:// URLs or absolute paths. Relative paths are resolved from the app's documents directory.
* - Android: Use absolute file paths or content:// URIs for files accessible via the Android Storage Access Framework.
* - Web: Use HTTP/HTTPS URLs. The file will be fetched and extracted in the browser.
*
* @since 7.0.0
* @example '/Users/app/Documents/archive.zip'
* @example '/var/mobile/Containers/Data/Application/.../Documents/backup.zip'
* @example 'file:///storage/emulated/0/Download/compressed.zip'
* @example 'https://example.com/files/archive.zip' (Web only)
*/
source: string;
/**
* Path to the directory where files will be extracted.
*
* The destination directory will be created if it doesn't exist. All files
* and folders from the archive will be extracted while preserving the
* directory structure.
*
* Platform-specific notes:
* - iOS: Use file:// URLs or absolute paths. Relative paths are resolved from the app's documents directory.
* - Android: Use absolute file paths. Includes protection against zip slip vulnerabilities.
* - Web: Not applicable. Files are downloaded individually to the browser's download folder.
*
* @since 7.0.0
* @example '/Users/app/Documents/extracted'
* @example '/var/mobile/Containers/Data/Application/.../Documents/files'
* @example 'file:///storage/emulated/0/Download/extracted-files'
*/
destination: string;
/**
* Optional password for decrypting password-protected archives.
*
* Required if the ZIP archive was encrypted with a password. If the password
* is incorrect, extraction will fail with an error.
*
* Platform-specific notes:
* - iOS: Supports password-protected ZIP archives.
* - Android: Supports AES-encrypted archives created with zip4j or standard password-protected ZIPs.
* - Web: Not supported. Password-protected archives cannot be extracted in the browser.
*
* @since 7.0.0
* @example 'mySecurePassword123'
*/
password?: string;
}

실질적 출처

Source Of Truth

이 페이지는 플러그인의 소스 코드에서 생성됩니다. src/definitions.ts. API의 공개 버전이 업스트림에서 변경되면 다시 싱크를 실행하세요.

Getting Started에서 계속 진행하세요

“시작부터 계속하기” 섹션

__CAPGO_KEEP_0__을 사용 중이라면 시작하기 API dashboard 및 API 연산을 계획하려면 API을 @capgo/capacitor-zip을 사용하여 @capgo/capacitor-zip의 네이티브 기능을 사용하는 경우 @capgo/capacitor-zip API 개요 API 개요의 구현 세부 정보 소개 소개의 구현 세부 정보 API 키 API 키의 구현 세부 정보 __CAPGO_KEEP_0__ __CAPGO_KEEP_1__