[Getting Started](https://capgo.com/ja/docs/plugins/uploader/getting-started/#getting-started)
このプラグインのインストールステップとフルマークダウンガイドまでの全てのステップを含むセットアップコマンドをコピーしてください。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-uploader`
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/uploader/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.
インストール
「インストール」のセクションCapgoの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-uploader` plugin in my project.Manual Setup を好みます場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の説明を参照してください。
bun add @capgo/capacitor-uploaderbunx cap syncImport
「Import」タイトルのセクションimport { Uploader } from '@capgo/capacitor-uploader';API オーバービュー
「API オーバービュー」タイトルのセクションstartUpload
「startUpload」タイトルのセクションサーバーにファイルをアップロードする
アップロードはアプリが閉じたりバックグラウンドに移動したりしてもバックグラウンドで続きます。 アップロードイベントをリスンして進捗、完了、または失敗を追跡してください。
import { Uploader } from '@capgo/capacitor-uploader';
const { id } = await Uploader.startUpload({ filePath: 'file:///path/to/file.jpg', serverUrl: 'https://example.com/upload', headers: { 'Authorization': 'Bearer token' }, method: 'POST', uploadType: 'multipart', fileField: 'photo'});console.log('Upload started with ID:', id);removeUpload
Section titled “removeUpload”進行中のアップロードをキャンセルして削除します。
アップロードが進行中の場合はアップロードを停止し、リソースをクリーンアップします。
import { Uploader } from '@capgo/capacitor-uploader';
await Uploader.removeUpload({ id: 'upload-123' });Type Reference
Section titled “Type Reference”uploadOption
Section titled “uploadOption”ファイルアップロードの設定オプション
export interface uploadOption { /** * The local file path of the file to upload. * Can be a file:// URL or an absolute path. * * @since 0.0.1 */ filePath: string;
/** * The server URL endpoint where the file should be uploaded. * * @since 0.0.1 */ serverUrl: string;
/** * The title of the upload notification shown to the user. * Android only. * * @default 'Uploading' * @since 0.0.1 */ notificationTitle?: string;
/** * HTTP headers to send with the upload request. * Useful for authentication tokens, content types, etc. * * @since 0.0.1 * @example * ```typescript * headers: { * 'Authorization': 'Bearer token123', * 'X-Custom-Header': 'value' * } * ``` */ headers: { [key: string]: string; };
/** * The HTTP method to use for the upload request. * * @default 'POST' * @since 0.0.1 */ method?: 'PUT' | 'POST';
/** * The MIME type of the file being uploaded. * If not specified, the plugin will attempt to determine it automatically. * * @since 0.0.1 * @example 'image/jpeg', 'application/pdf', 'video/mp4' */ mimeType?: string;
/** * Additional form parameters to send with the upload request. * These will be included as form data in multipart uploads. * * @since 0.0.1 */ parameters?: { [key: string]: string };
/** * The maximum number of times to retry the upload if it fails. * * @since 0.0.1 * @default 0 */ maxRetries?: number;
/** * The type of upload to perform. * - 'binary': Uploads the file as raw binary data in the request body * - 'multipart': Uploads the file as multipart/form-data * * @default 'binary' * @since 0.0.2 */ uploadType?: 'binary' | 'multipart';
/** * The form field name for the file when using multipart upload type. * Only used when uploadType is 'multipart'. * * @default 'file' * @since 0.0.2 */ fileField?: string;}UploadEvent
Section titled “UploadEvent”アップロードライフサイクル中の発生イベント
export interface UploadEvent { /** * The current status of the upload. * - 'uploading': Upload is in progress * - 'completed': Upload finished successfully * - 'failed': Upload encountered an error * * @since 0.0.1 */ name: 'uploading' | 'completed' | 'failed';
/** * Additional data about the upload event. * * @since 0.0.1 */ payload: { /** * Upload progress percentage from 0 to 100. * Only present during 'uploading' events. * * @since 0.0.1 */ percent?: number;
/** * Error message if the upload failed. * Only present during 'failed' events. * * @since 0.0.1 */ error?: string;
/** * HTTP status code returned by the server. * Present during 'completed' and 'failed' events. * * @since 0.0.1 */ statusCode?: number; };
/** * Unique identifier for this upload task. * * @since 0.0.1 */ id: string;}真実の源
「真実の源」このページはプラグインの src/definitions.tsパブリックAPIがアップストリームで変更されたときは、再度同期を実行してください。
始めから始める
「始めから始める」あなたが 始めから始める を使用してダッシュボードとAPIの作業を計画している場合、 Using @capgo/capacitor-uploader for the native capability in Using @capgo/capacitor-uploader, APIの概要 実装詳細については API の概要を参照してください。 概要 実装詳細については概要を参照してください。 API キー 実装詳細については API キー、 デバイス 実装詳細についてはデバイスを参照してください。