跳过内容

Getting Started

终端窗口
bun add @capgo/capacitor-downloader
bunx cap sync
import { CapacitorDownloader } from '@capgo/capacitor-downloader';

download

下载标题

开始新下载任务。

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

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当公共API在上游发生变化时,请重新运行同步。

继续从开始

继续从开始

如果您正在使用 开始 规划仪表板和API操作,连接它 使用@capgo/capacitor-下载器 使用@capgo/capacitor-下载器中的本机功能 API概述 API概述中的实现细节 介绍 介绍中的实现细节 API密钥 API密钥中的实现细节 设备 设备中的实现细节