시작하기
이 플러그인의 설치 단계와 전체 마크다운 가이드가 포함된 설정 프롬프트를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-firebase-storage`
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/firebase-storage/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.
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-firebase-storage` plugin in my project.수동 설정을 선호한다면, 다음 명령어를 실행하여 플러그인을 설치하고 아래의 플랫폼별 지침을 따르세요:
bun add @capgo/capacitor-firebase-storagenpx cap sync가져오기
“Import” 섹션import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';빠른 시작
“빠른 시작” 섹션import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
await FirebaseStorage.deleteFile({ path: 'mountains.png' });예제: getDownloadUrl
“예제: getDownloadUrl” 제목의 섹션import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
const result = await FirebaseStorage.getDownloadUrl({ path: 'mountains.png' });console.log(result);예시: getMetadata
“Example: getMetadata” 섹션import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
const result = await FirebaseStorage.getMetadata({ path: 'mountains.png' });console.log(result);자주 하는 실수
“흔한 실수” 섹션- 네이티브 동기화: 실행
npx cap sync플러그인 업그레이드 후. - 신뢰할 수 있는 소스: 신뢰
src/definitions.tsGitHub 레포지토리에서.
API 개요
“API 개요” 섹션deleteFile
“deleteFile” 섹션파일을 삭제합니다.
import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
await FirebaseStorage.deleteFile({ path: 'mountains.png' });getDownloadUrl
“getDownloadUrl” 섹션파일의 다운로드 URL을 가져옵니다.
import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
const result = await FirebaseStorage.getDownloadUrl({ path: 'mountains.png' });console.log(result);getMetadata
“getMetadata” 섹션파일의 메타데이터를 가져옵니다.
import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
const result = await FirebaseStorage.getMetadata({ path: 'mountains.png' });console.log(result);listFiles
“listFiles” 섹션디렉토리 내 파일 목록을 불러옵니다.
import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
const result = await FirebaseStorage.listFiles({ path: 'path/to/file' });// The result holds sensitive values: use it without logging it.updateMetadata
“updateMetadata” 섹션파일의 메타데이터를 업데이트합니다.
import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
await FirebaseStorage.updateMetadata({ path: 'path/to/file', metadata: {},});uploadFile
“uploadFile” 섹션파일을 업로드합니다.
import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
const result = await FirebaseStorage.uploadFile({ path: 'mountains.png' }, (event, error) => { console.log(event);});console.log(result);useEmulator
“useEmulator” 섹션Cloud Storage 에뮬레이터와 통신하도록 앱을 설정하세요.
Android에서는 cleartext traffic을 허용해야 합니다. Capacitor 설정에서는:
{ server: { cleartext: true }}cleartext traffic은 프로덕션 환경용이 아닙니다.
import { FirebaseStorage } from '@capgo/capacitor-firebase-storage';
await FirebaseStorage.useEmulator({ host: "127.0.0.1" });타입 레퍼런스
“타입 참조” 섹션DeleteFileOptions
“DeleteFileOptions” 섹션export interface DeleteFileOptions { /** * The full path to the file to delete, including the file name. * * @since 5.3.0 * @example 'mountains.png' * @example 'images/mountains.png' */ path: string;}GetDownloadUrlOptions
“GetDownloadUrlOptions” 섹션export interface GetDownloadUrlOptions { /** * The full path to the file to get the download url for, including the file name. * * @since 5.3.0 * @example 'mountains.png' * @example 'images/mountains.png' */ path: string;}GetDownloadUrlResult
“GetDownloadUrlResult” 섹션export interface GetDownloadUrlResult { /** * The download url for the file. * * @since 5.3.0 */ downloadUrl: string;}GetMetadataOptions
“GetMetadataOptions” 섹션export interface GetMetadataOptions { /** * The full path to the file to get the metadata for, including the file name. * * @since 5.3.0 * @example 'mountains.png' * @example 'images/mountains.png' */ path: string;}GetMetadataResult
“GetMetadataResult” 섹션export interface GetMetadataResult { /** * The bucket this file is contained in. * * @since 5.3.0 */ bucket: string; /** * The timestamp at which the file was created in milliseconds since the epoch. * * @since 5.3.0 * @example 1697304435933 */ createdAt?: number; /** * The object's generation. * * @since 5.3.0 * @see https://cloud.google.com/storage/docs/metadata#generation-number */ generation: string; /** * The md5 hash of the file. * * @since 5.3.0 */ md5Hash?: string; /** * The object's metadata generation. * * @since 5.3.0 * @see https://cloud.google.com/storage/docs/metadata#generation-number */ metadataGeneration: string; /** * The short name of this file, which is the last component of the full path. * * @since 5.3.0 * @example 'mountains.png' */ name?: string; /** * The full path to the file, including the file name. * * @since 5.3.0 * @example 'images/mountains.png' */ path?: string; /** * The size of the file in bytes. * * @since 5.3.0 */ size: number; /** * The timestamp at which the file was last updated in milliseconds since the epoch. * * @since 5.3.0 * @example 1697304435933 */ updatedAt: number; /** * Served as the `Cache-Control` header on object download. * * @since 6.1.0 */ cacheControl?: string; /** * Served as the `Content-Disposition` header on object download. * * @since 6.1.0 */ contentDisposition?: string; /** * Served as the `Content-Encoding` header on object download. * * @since 6.1.0 */ contentEncoding?: string; /** * Served as the `Content-Language` header on object download. * * @since 6.1.0 */ contentLanguage?: string; /** * Served as the `Content-Type` header on object download. * * @since 6.1.0 */ contentType?: string; /** * Additional user-defined custom metadata. * * @since 6.1.0 */ customMetadata?: { [key: string]: string };}ListFilesOptions
“ListFilesOptions” 섹션export interface ListFilesOptions { /** * The full path to the directory to list files for. * * @since 5.3.0 */ path: string; /** * The maximum number of results to return. * * @since 5.3.0 * @default 1000 */ maxResults?: number; /** * The page token, returned by a previous call to this method. * If provided, listing is resumed from the previous position. * * @since 5.3.0 */ pageToken?: string;}ListFilesResult
“ListFilesResult” 섹션export interface ListFilesResult { /** * The list of files in the directory. * * @since 5.3.0 */ items: StorageReference[]; /** * If set, there might be more results for this list. * Use this token to resume the list. * * @since 5.3.0 */ nextPageToken?: string;}UpdateMetadataOptions
“UpdateMetadataOptions” 섹션export interface UpdateMetadataOptions { /** * The full path to the file to update the metadata for, including the file name. * * @since 5.3.0 */ path: string; /** * The metadata to update. * * @since 5.3.0 */ metadata: SettableMetadata;}UploadFileOptions
“UploadFileOptions” 섹션export interface UploadFileOptions { /** * The data to upload. * * Only available for Web. * * @since 5.3.0 */ blob?: Blob; /** * The full path where data should be uploaded, including the file name. * * @since 5.3.0 * @example 'mountains.png' * @example 'images/mountains.png' */ path: string; /** * The uri to the file to upload. * * Only available for Android and iOS. * * @since 5.3.0 * @example 'content://com.google.android.apps.photos.contentprovider/-1/1/content://media/external/images/media/1000000214/ORIGINAL/NONE/image/.png/mountains' * @example 'file:///var/mobile/Containers/Data/Application/E397A70D-67E4-4258-236E-W1D9E12111D4/Library/Caches/092F8464-DE60-40B3-8A23-EB83160D9F9F/mountains.png' */ uri?: string; /** * The metadata to set for the file. * * @since 5.4.0 */ metadata?: UploadMetadata;}UploadFileCallback
“UploadFileCallback” 섹션export type UploadFileCallback = (event: UploadFileCallbackEvent | null, error: any) => void;CallbackId
“CallbackId” 섹션export type CallbackId = string;UseEmulatorOptions
“UseEmulatorOptions” 섹션export interface UseEmulatorOptions { /** * The emulator host without any port or scheme. * * Note when using a Android Emulator device: 10.0.2.2 is the special IP address to connect to the 'localhost' of the host computer. * * @since 6.1.0 * @example "127.0.0.1" */ host: string; /** * The emulator port. * * @since 6.1.0 * @default 9199 * @example 9199 */ port?: number;}Source of Truth
“Source Of Truth” 섹션이 페이지는 플러그인의 src/definitions.tsupstream에서 public API가 변경되면 sync를 다시 실행하세요.
시작하기 다음 단계
“Getting Started에서 계속하기” 섹션사용 중이라면 시작하기 저장 공간과 파일 처리를 계획하려면, 다음 항목과 연결하세요 @capgo/capacitor-data-storage-sqlite @capgo/capacitor-data-storage-sqlite의 구현 세부 사항은, @capgo/capacitor-data-storage-sqlite 사용하기 @capgo/capacitor-data-storage-sqlite 사용 시 네이티브 기능을 위해, @capgo/capacitor-file @capgo/capacitor-file의 구현 세부 사항은, @capgo/capacitor-file 사용하기 @capgo/capacitor-file 사용 시 네이티브 기능에 대해서는, 그리고 @capgo/capacitor-uploader @capgo/capacitor-uploader.의 구현 세부 사항에 대해서는