시작하기
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-file-sharer`
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-sharer/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-file-sharer` plugin in my project.Manual Setup을 사용하는 경우, 플러그인을 설치하려면 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요:
bun add @capgo/capacitor-file-sharerbunx cap syncImport
Importimport { FileSharer } from '@capgo/capacitor-file-sharer';Base64 파일 공유
Base64 파일 공유 섹션import { FileSharer } from '@capgo/capacitor-file-sharer';
await FileSharer.share({ filename: 'report.pdf', contentType: 'application/pdf', base64Data: reportBase64, title: 'Quarterly report', text: 'Attached report',});base64Data Base64 문자열 또는 데이터 URL (예: data:application/octet-stream;base64,SGVsbG8gd29ybGQh)일 수 있습니다. data:application/pdf;base64,....
지역 파일 공유
지역 파일 공유 섹션await FileSharer.share({ filename: 'export.zip', contentType: 'application/zip', path: fileUri,});네이티브 구현은 지역 경로, URL, Android URI, URI 및 __CAPGO_KEEP_0__ URL을 지원합니다. file:// URL content:// URIs, and Capacitor _capacitor_file_ URL
파일 저장
파일 저장 섹션const result = await FileSharer.save({ filename: 'backup.zip', contentType: 'application/zip', base64Data: zipBase64, android: { saveDirectory: 'downloads', relativePath: 'Download/My App', },});
console.log(result.uri);안드로이드 저장 디렉토리는 downloads, pictures, movies, music, 그리고 documents. 안드로이드 10 이상에서는 MediaStore를 통해 파일을 저장하고, 안드로이드 9 이하에서는 manifest WRITE_EXTERNAL_STORAGE 권한과 함께 사용합니다. maxSdkVersion=28.
파일과 함께 텍스트 공유
파일과 텍스트 공유 섹션await FileSharer.share({ filename: 'photo.jpg', contentType: 'image/jpeg', path: photoUri, title: 'Site photo', subject: 'Photo export', text: 'Captured during inspection.',});text 안드로이드에서는 EXTRA_TEXT iOS에서는 두 번째 액티비티 아이템으로 전달됩니다.
타입 참조
타입 참조 섹션ShareFileOptions
ShareFileOptions 섹션export interface ShareFileOptions { filename: string; base64Data?: string; path?: string; contentType?: string; text?: string; title?: string; subject?: string; android?: AndroidFileSharerOptions;}AndroidFileSharerOptions
AndroidFileSharerOptions 섹션export interface AndroidFileSharerOptions { chooserTitle?: string; saveDirectory?: 'downloads' | 'pictures' | 'movies' | 'music' | 'documents'; relativePath?: string;}SaveFileResult
SaveFileResult 섹션export interface SaveFileResult { uri?: string;}오류 코드
오류 코드 섹션ERR_PARAM_NO_FILENAME-filename값이 누락되거나 비어 있습니다.ERR_PARAM_NO_DATA- 둘 중 하나도 없습니다.base64Data아니요path제공되지 않았습니다.ERR_PARAM_DATA_INVALID- base64 입력이 디코딩되지 않았습니다.ERR_LOCAL_FILE_NOT_FOUND- 제공된 로컬 경로 또는 콘텐츠 URI가 열리지 않았습니다.ERR_FILE_CACHING_FAILED- 네이티브 임시 파일이 작성되지 않았습니다.ERR_FILE_SAVE_FAILED- 안드로이드가 공용 저장소에 파일을 저장하지 못했습니다.ERR_ACTIVITY_NOT_FOUND- 안드로이드가 공유 대상 열지 못했습니다.USER_CANCELLED- iOS 공유 시트가 완료되지 않고 닫혔습니다.
진실의 근원
제목이 '진실의 근원'인 섹션이 페이지는 플러그인의 src/definitions.ts을 추적합니다. 다시 싱크를 실행할 때 upstream의 API이 변경되면.
다음 단계로 진행하세요
다음 단계로 진행하세요이러한 기능을 사용하고 있다면 Getting Started 파일 저장 및 처리를 계획하고 있다면 Using @capgo/capacitor-file-sharer for the native capability in Using @capgo/capacitor-file-sharer, @capgo/capacitor-data-storage-sqlite for the implementation detail in @capgo/capacitor-data-storage-sqlite, Using @capgo/capacitor-data-storage-sqlite @capgo/capacitor-file-sharer @capgo/capacitor-data-storage-sqlite 구현 세부 사항에 대한 @capgo/capacitor-파일 Using @capgo/capacitor-파일 Using @capgo/capacitor-파일의 원시 기능