시작하기
이 플러그인의 설치 단계와 전체 markdown 가이드가 포함된 설정 프롬프트를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-downloader`
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/downloader/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 지원 설정으로 플러그인을 설치할 수 있습니다. 다음 명령어로 AI 도구에 Capgo 스킬을 추가하세요:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins그다음 아래 prompt를 사용하세요:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-downloader` plugin in my project.Manual Setup을 선호한다면, 다음 명령어를 실행하여 플러그인을 설치하고 아래의 플랫폼별 지침을 따르세요:
bun add @capgo/capacitor-downloaderbunx cap sync가져오기
“Import” 섹션import { CapacitorDownloader } from '@capgo/capacitor-downloader';빠른 시작
“Quick start” 섹션지정된 폴더로 다운로드하고, 진행 상황을 모니터링하며, 지원되는 경우 앱 재시작 후에도 다운로드를 재개할 수 있습니다.
import { CapacitorDownloader } from '@capgo/capacitor-downloader';
const progressListener = await CapacitorDownloader.addListener('downloadProgress', (event) => { if (event.id === 'offline-pack') { console.log(event.progress); }});
const task = await CapacitorDownloader.download({ id: 'offline-pack', url: 'https://cdn.example.com/large-pack.zip', destination: 'downloads/offline-pack.zip',});예시: 일시 중지 및 재개
“예시: 일시 중지 및 재개” 섹션await CapacitorDownloader.pause({ id: 'offline-pack' });await CapacitorDownloader.resume({ id: 'offline-pack' });예시: 완료된 파일 검사하기
“예시: 완료된 파일 검사하기” 섹션import { Capacitor } from '@capacitor/core';import { Directory, Filesystem } from '@capacitor/filesystem';
const relativePath = 'downloads/offline-pack.zip';const path = Capacitor.getPlatform() === 'ios' ? (await Filesystem.getUri({ directory: Directory.Documents, path: relativePath })).uri : relativePath;
const info = await CapacitorDownloader.getFileInfo({ path });자주 하는 실수
“자주 하는 실수” 섹션- 저장 위치: 다음 중 선택하세요
destination앱이 각 플랫폼에서 읽을 수 있는 경로입니다. - 백그라운드: iOS 및 Android에서는 백그라운드에서 다운로드가 실행됩니다. Web의 경우,
download()기능이 구현되지 않았으므로 브라우저 다운로드 흐름을 사용하세요. - 상태: 사용
checkStatus앱 프로세스가 살아있는 동안에만 가능합니다. iOS에서는 앱 재실행 시 task ID가 복구되지 않습니다.
API 개요
“API 개요” 섹션download
“download” 섹션새로운 download 작업을 시작합니다.
import { CapacitorDownloader } from '@capgo/capacitor-downloader';
const task = await CapacitorDownloader.download({ id: 'my-download', url: 'https://example.com/file.pdf', destination: 'downloads/file.pdf'});pause
“pause” 섹션진행 중인 download를 일시 중지합니다. 나중에 중단된 지점부터 다시 download를 재개할 수 있습니다.
import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.pause({ id: 'id-123' });resume
“resume” 섹션일시 중지된 다운로드를 재개합니다. 중단된 시점부터 다시 시작합니다.
import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.resume({ id: 'id-123' });stop
“stop” 섹션다운로드를 중단하고 영구적으로 취소합니다. 다운로드된 데이터는 삭제됩니다.
import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.stop({ id: 'id-123' });checkStatus
“checkStatus” 섹션다운로드의 현재 상태를 확인합니다.
import { CapacitorDownloader } from '@capgo/capacitor-downloader';
const result = await CapacitorDownloader.checkStatus({ id: 'id-123' });console.log(result);getFileInfo
“getFileInfo” 섹션다운로드된 파일에 대한 정보를 가져옵니다.
import { CapacitorDownloader } from '@capgo/capacitor-downloader';
const result = await CapacitorDownloader.getFileInfo({ path: 'path/to/file' });console.log(result);타입 참조
“타입 레퍼런스” 섹션DownloadOptions
“DownloadOptions” 섹션다운로드를 시작하기 위한 설정 옵션입니다.
export interface DownloadOptions { /** Unique identifier for this download task */ id: string; /** URL of the file to download */ url: string; /** Local file path where the download will be saved */ destination: string; /** Optional HTTP headers to include in the request */ headers?: { [key: string]: string }; /** Network type requirement for download */ network?: 'cellular' | 'wifi-only'; /** Download priority level */ priority?: 'high' | 'normal' | 'low';}DownloadTask
“DownloadTask” 섹션다운로드 작업의 현재 상태와 진행 상황을 나타냅니다.
export interface DownloadTask { /** Unique identifier for the download task */ id: string; /** Download progress from 0 to 100 */ progress: number; /** Current state of the download */ state: 'PENDING' | 'RUNNING' | 'PAUSED' | 'DONE' | 'ERROR';}기준 소스
“기준 소스” 섹션이 페이지는 플러그인의 src/definitions.ts에서 생성되었습니다. public API가 업스트림에서 변경되면 동기화를 다시 실행하세요.
Getting Started에서 계속하기
“Getting Started에서 계속하기”라는 제목의 섹션사용 중인 경우 시작하기 대시보드와 API 운영을 계획하려면, 이를 다음 항목과 연결하세요: @capgo/capacitor-downloader 사용하기 @capgo/capacitor-downloader를 사용하여 Native Build 기능을 구현하려면, API 개요 API Overview의 구현 상세 내용은 소개 Introduction의 구현 상세 내용은 API 키 API Keys의 구현 세부 사항은, 디바이스 Devices의 구현 세부 사항은.