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-file-picker`
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/file-picker/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アシストセットアップを使用してプラグインをインストールできます。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-file-picker` plugin in my project.Manualセットアップを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-file-pickerbunx cap syncインポート
「インポート」のセクションimport { CapgoFilePicker } from '@capgo/capacitor-file-picker';API オーバービュー
「API オーバービュー」のセクションpickFiles
「pickFiles」のセクションデバイスから1つ以上のファイルを選択してください。
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickFiles({ types: ['application/pdf', 'image/*'], limit: 5, readData: false});console.log('Picked files:', result.files);pickImages
「pickImages」のセクションギャラリーより1つ以上の画像を選択してください。 Android/iOSのみ。
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickImages({ limit: 10, readData: false});console.log('Picked images:', result.files);pickVideos
「pickVideos」セクションギャラリーから1つ以上の動画を選択してください。 Android/iOSのみ。
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickVideos({ limit: 3, skipTranscoding: true});console.log('Picked videos:', result.files);pickMedia
「pickMedia」セクションギャラリーから1つ以上の画像または動画を選択してください。 Android/iOSのみ。
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickMedia({ limit: 5, readData: true});console.log('Picked media:', result.files);pickDirectory
「pickDirectory」セクションデバイスからディレクトリを選択してください。 Android/iOSのみ。
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.pickDirectory();console.log('Selected directory:', result.path);convertHeicToJpeg
「convertHeicToJpeg」セクションHEIC画像をJPEG形式に変換します。 iOSのみ。
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const result = await CapgoFilePicker.convertHeicToJpeg({ path: '/path/to/image.heic', quality: 0.9});console.log('Converted file:', result.path);copyFile
ファイルのコピーファイルを新しい場所にコピーします。
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
await CapgoFilePicker.copyFile({ from: '/source/file.pdf', to: '/destination/file.pdf', overwrite: true});checkPermissions
ファイルの読み取り権限の確認Android専用:ファイルの読み取り権限を確認します。
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const status = await CapgoFilePicker.checkPermissions();console.log('Read permission:', status.readExternalStorage);requestPermissions
ファイルの読み取り権限の要求Android専用:ファイルの読み取り権限を要求します。
import { CapgoFilePicker } from '@capgo/capacitor-file-picker';
const status = await CapgoFilePicker.requestPermissions();if (status.readExternalStorage === 'granted') { console.log('Permission granted');}型の参照
型の参照PickFilesOptions
ファイルの選択オプションファイルを選択するためのオプション。
export interface PickFilesOptions { /** * List of accepted MIME types or file extensions. * On iOS, only MIME types are supported. * Examples: ['image/*'], ['application/pdf'], ['.pdf', '.doc'] */ types?: string[]; /** * Maximum number of files to pick. * Set to 0 for unlimited (platform default). * @default 0 */ limit?: number; /** * Whether to read the file data as base64. * Note: Reading large files may cause memory issues. * @default false */ readData?: boolean;}PickFilesResult
セクション「ファイルを選択する結果」ファイルを選択する結果
export interface PickFilesResult { /** Array of picked files */ files: PickedFile[];}PickMediaOptions
セクション「メディアを選択するオプション」メディア (画像/動画) を選択するためのオプション。
export interface PickMediaOptions { /** * Maximum number of files to pick. * Set to 0 for unlimited (platform default). * @default 0 */ limit?: number; /** * Whether to read the file data as base64. * Note: Reading large files may cause memory issues. * @default false */ readData?: boolean; /** * iOS only: Skip transcoding of videos. * @default false */ skipTranscoding?: boolean; /** * iOS 15+ only: Show ordered selection badges. * @default false */ ordered?: boolean;}PickDirectoryResult
セクション「ディレクトリを選択する結果」ディレクトリを選択する結果
export interface PickDirectoryResult { /** The path to the selected directory */ path: string;}ConvertHeicToJpegOptions
セクション「HEICをJPEGに変換するオプション」HEICをJPEGに変換するためのオプションです。
export interface ConvertHeicToJpegOptions { /** The path to the HEIC file to convert */ path: string; /** * The compression quality for JPEG (0.0 - 1.0). * @default 0.9 */ quality?: number;}ConvertHeicToJpegResult
「ConvertHeicToJpegResult」セクションHEICをJPEGに変換した結果です。
export interface ConvertHeicToJpegResult { /** The path to the converted JPEG file */ path: string;}CopyFileOptions
「CopyFileOptions」セクションファイルをコピーするためのオプションです。
export interface CopyFileOptions { /** Source file path */ from: string; /** Destination file path */ to: string; /** * Whether to overwrite if destination exists. * @default false */ overwrite?: boolean;}PermissionStatus
「PermissionStatus」セクションファイルへのアクセスの許可状況です。
export interface PermissionStatus { /** Whether permission to read media files is granted */ readExternalStorage: PermissionState; /** Whether permission to access media location is granted */ accessMediaLocation?: PermissionState;}PickerDismissedListener
「PickerDismissedListener」セクションリスナーキャラバックのピッカー解除イベント
export type PickerDismissedListener = (event: null) => void;PickedFile
「選択されたファイル」セクション選択されたファイルを表す
export interface PickedFile { /** The name of the file */ name: string; /** The path to the file */ path?: string; /** The MIME type of the file */ mimeType: string; /** The size of the file in bytes */ size: number; /** * The base64 encoded data of the file. * Only present if readData was true. */ data?: string; /** * The Blob instance of the file. * Web only. */ blob?: Blob; /** Width in pixels (images/videos only) */ width?: number; /** Height in pixels (images/videos only) */ height?: number; /** Duration in seconds (videos only) */ duration?: number; /** Last modified timestamp in milliseconds */ modifiedAt?: number;}PermissionState
「許可状態」セクション許可状態の値
export type PermissionState = 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';真実の源
「真実の源」セクションこのページはプラグインの src/definitions.tsAPIのパブリック変更を再度Syncするときは
Getting Startedから続けてください
Getting Startedのセクションのタイトルは「Getting Startedから続けてください」Capgoを使用している場合 Getting Started Capgoを使用して Using @capgo/capacitor-file-picker @capgo/capacitor-file-picker @capgo/capacitor-file-pickerのネイティブ機能の実装 @capgo/capacitor-data-storage-sqlite @capgo/capacitor-data-storage-sqliteの実装詳細 @capgo/capacitor-data-storage-sqlite @capgo/capacitor-data-storage-sqliteのネイティブ機能の実装 実装詳細については@capgo/capacitor-ファイルを参照してください。 Using @capgo/capacitor-ファイル native機能についてはUsing @capgo/capacitor-ファイルを参照してください。