내용으로 바로가기

Getting Started

GitHub

설치

설치

플러그인을 설치하는 데 사용할 수 있는 AI-assisted 설정을 사용할 수 있습니다. 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-photo-library` plugin in my project.

만약 Manual Setup을 선호한다면, 플러그인을 설치하려면 다음 명령어를 실행하고 아래에 플랫폼에 따라 설명된 지침을 따르세요:

터미널 창
bun add @capgo/capacitor-photo-library
bunx cap sync

수입

Import
import { PhotoLibrary } from '@capgo/capacitor-photo-library';

API 개요

API 개요

checkAuthorization

권한 확인

사용자에게 권한 요청 없이 현재 권한 상태를 반환합니다.

import { PhotoLibrary } from '@capgo/capacitor-photo-library';
const result = await PhotoLibrary.checkAuthorization();
console.log(result);

requestAuthorization

권한 요청

사진 앨범에 접근이 필요하면 권한을 요청합니다.

import { PhotoLibrary } from '@capgo/capacitor-photo-library';
const result = await PhotoLibrary.requestAuthorization();
console.log(result);

getAlbums

getAlbums

가용 앨범을 가져옵니다.

import { PhotoLibrary } from '@capgo/capacitor-photo-library';
const result = await PhotoLibrary.getAlbums();
console.log(result);

getLibrary

getLibrary

라이브러리 자산과 웹 뷰에서 표시할 수 있는 URL을 함께 가져옵니다.

import { PhotoLibrary } from '@capgo/capacitor-photo-library';
const result = await PhotoLibrary.getLibrary();
console.log(result);

getPhotoUrl

getPhotoUrl

전체 해상도 버전의 자산의 표시 가능한 URL을 가져옵니다. 이미 getLibrary with includeFullResolutionData이 메서드를 호출한 경우 일반적으로 이 메서드를 다시 호출할 필요가 없습니다.

import { PhotoLibrary } from '@capgo/capacitor-photo-library';
const result = await PhotoLibrary.getPhotoUrl({ id: 'id-123' });
console.log(result);

getThumbnailUrl

getThumbnailUrl

자산의 리사이즈된 썸네일 URL을 가져옵니다.

import { PhotoLibrary } from '@capgo/capacitor-photo-library';
const result = await PhotoLibrary.getThumbnailUrl({ id: 'id-123' });
console.log(result);

사용자가 전체 사진 앨범 접근 권한을 부여하지 않고도 미디어를 선택할 수 있는 네이티브 시스템 픽커를 열어줍니다. 선택한 파일은 애플리케이션 캐시로 복사되고 포트러블 URL로 반환됩니다.

import { PhotoLibrary } from '@capgo/capacitor-photo-library';
const result = await PhotoLibrary.pickMedia();
console.log(result);
export type PhotoLibraryAuthorizationState = 'authorized' | 'limited' | 'denied' | 'notDetermined';
export interface PhotoLibraryAlbum {
id: string;
title: string;
assetCount: number;
}
export interface GetLibraryOptions {
/**
* Number of assets to skip from the beginning of the query.
*/
offset?: number;
/**
* Maximum number of assets to return. Omit to return everything that matches.
*/
limit?: number;
/**
* Include images in the result. Defaults to `true`.
*/
includeImages?: boolean;
/**
* Include videos in the result. Defaults to `false`.
*/
includeVideos?: boolean;
/**
* Include information about the albums each asset belongs to. Defaults to `false`.
*/
includeAlbumData?: boolean;
/**
* Include assets stored in the cloud (iCloud / Google Photos). Defaults to `true`.
*/
includeCloudData?: boolean;
/**
* If `true`, use the original filenames reported by the OS when available.
*/
useOriginalFileNames?: boolean;
/**
* Width of the generated thumbnails. Defaults to `512`.
*/
thumbnailWidth?: number;
/**
* Height of the generated thumbnails. Defaults to `384`.
*/
thumbnailHeight?: number;
/**
* JPEG quality for generated thumbnails (0-1). Defaults to `0.5`.
*/
thumbnailQuality?: number;
/**
* When `true`, copies the full sized asset into the app cache and returns its URL.
* Defaults to `false`.
*/
includeFullResolutionData?: boolean;
}
export interface GetLibraryResult {
assets: PhotoLibraryAsset[];
/**
* Total number of assets matching the query in the library. `assets.length` can be less
* than this value when pagination is used.
*/
totalCount: number;
/** Whether more assets are available when using pagination. */
hasMore: boolean;
}

PhotoLibraryFile

PhotoLibraryFile 섹션
export interface PhotoLibraryFile {
/** Absolute path on the native file system. */
path: string;
/**
* URL that can be used inside a web view. Usually produced by `Capacitor.convertFileSrc(path)`.
*/
webPath: string;
mimeType: string;
/** Size in bytes if known, otherwise `-1`. */
size: number;
}

PickMediaOptions

PickMediaOptions 섹션
export interface PickMediaOptions {
/**
* Maximum number of items the user can select. Use `0` to allow unlimited selection.
* Defaults to `1`.
*/
selectionLimit?: number;
/** Allow the user to select images. Defaults to `true`. */
includeImages?: boolean;
/** Allow the user to select videos. Defaults to `false`. */
includeVideos?: boolean;
/** Width of the generated thumbnails for picked items. Defaults to `256`. */
thumbnailWidth?: number;
/** Height of the generated thumbnails for picked items. Defaults to `256`. */
thumbnailHeight?: number;
/** JPEG quality for generated thumbnails (0-1). Defaults to `0.7`. */
thumbnailQuality?: number;
}

PickMediaResult

PickMediaResult 섹션
export interface PickMediaResult {
assets: PhotoLibraryAsset[];
}

PhotoLibraryAsset

PhotoLibraryAsset 섹션
export interface PhotoLibraryAsset {
id: string;
fileName: string;
type: PhotoAssetType;
width: number;
height: number;
duration?: number;
creationDate?: string;
modificationDate?: string;
latitude?: number;
longitude?: number;
mimeType: string;
/** Size in bytes reported by the OS for the underlying asset, if available. */
size?: number;
albumIds?: string[];
thumbnail?: PhotoLibraryFile;
file?: PhotoLibraryFile;
}

PhotoAssetType

PhotoAssetType 섹션
export type PhotoAssetType = 'image' | 'video';

실질적인 출처

Source Of Truth

이 페이지는 플러그인의 src/definitions.ts Re-run the sync when the public API changes upstream.

이러한 기능을 사용하는 경우 Getting Started 계획 대시보드 및 API 운영을 위해 Using @capgo/capacitor-photo-library Using @capgo/capacitor-photo-library API 개요 API Overview 소개 소개에 대한 구현 세부 정보를 위해 API 키 API 키에 대한 구현 세부 정보를 위해, 장치 장치에 대한 구현 세부 정보를 위해.