Skip to content

Getting Started

ターミナルウィンドウ
bun add @capgo/capacitor-downloader
bunx cap sync
import { CapacitorDownloader } from '@capgo/capacitor-downloader';

新しいダウンロードタスクを開始する

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
const task = await Downloader.download({
id: 'my-download',
url: 'https://example.com/file.pdf',
destination: 'downloads/file.pdf'
});

ダウンロードを一時停止する。 同じ位置から再開できる。

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.pause({} as { id: string });

一時停止したダウンロードを再開する。 一時停止した位置から続きます。

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.resume({} as { id: string });

ダウンロードを停止してキャンセルする。 ダウンロードしたデータは削除されます。

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.stop({} as { id: string });

ダウンロードの現在の状態を確認します。

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.checkStatus({} as { id: string });

ダウンロードしたファイルの情報を取得します。

import { CapacitorDownloader } from '@capgo/capacitor-downloader';
await CapacitorDownloader.getFileInfo({} as { path: string });

ダウンロードを開始するための設定オプションです。

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

ダウンロードタスクの現在の状態と進行状況を表します。

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パブリック API がアップストリームで変更された場合に再度同期を実行してください。

Getting Started から続けて

Getting Started から続けてのタイトル

あなたが Getting Started ダッシュボードとAPIの作業を計画するには、 Using @capgo/capacitor-downloader Using @capgo/capacitor-downloader APIの概要 APIの実装詳細 導入 __CAPGO_KEEP_0__のキー APIの実装詳細 for the implementation detail in API Keys, and __CAPGO_KEEP_0__の実装詳細 ページを編集