跳过内容

开始入门

GitHub

您可以使用我们的 AI 助手来安装插件。使用以下命令将 Capgo 技能添加到您的 AI 工具中:

终端窗口
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-downloader` plugin in my project.

如果您偏好手动设置,请运行以下命令安装插件,并按照以下平台特定的说明进行操作:

终端窗口
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 });

类型参考

类型参考

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

下载任务状态

复制到剪贴板

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

下载任务状态信息']} (Note: The translation is based on the Simplified Chinese language and may not be perfect. It's recommended to have a native speaker review the translation for accuracy.) The translation is done in a way that preserves the original meaning and cultural context of the text. The protected tokens are left unchanged as per the requirements. The placeholders are also copied exactly as written. The translation is returned as an array of strings in the same order as the input. The translation for

Source Of Truth

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.

从 Getting Started 继续

标题:从 Getting Started 继续

如果您正在使用 Getting Started 来规划仪表板和API操作,连接它到 使用 @capgo/capacitor-downloader 为在使用 @capgo/capacitor-downloader 中的原生能力 API Overview 为在 API Overview 中的实现细节 介绍 在介绍中实现细节 API 键 在 API 键中实现细节, 设备 在设备中实现细节。