Skip to content

Getting Started

GitHub
터미널 창
bun add @capgo/capacitor-uploader
bunx cap sync
import { Uploader } from '@capgo/capacitor-uploader';

__CAPGO_KEEP_0__ 서버에 파일 업로드를 시작합니다.

앱이 종료되거나 백그라운드에 있을 때도 업로드는 계속 진행됩니다. 업로드 진행, 완료, 또는 실패를 추적하기 위해 업로드 이벤트를 듣세요.

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);

__CAPGO_KEEP_0__ 진행 중인 업로드를 취소하고 제거합니다.

이것은 업로드가 진행 중일 때 업로드를 중단하고 리소스를 정리합니다.

import { Uploader } from '@capgo/capacitor-uploader';
await Uploader.removeUpload({ id: 'upload-123' });

__CAPGO_KEEP_0__ 참조

타입 참조 섹션

파일 업로드에 대한 구성 옵션입니다.

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;
}

업로드 라이프 사이클 중에 발생하는 이벤트입니다.

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를 다시 동기화할 때입니다.

Getting Started에서 계속 진행

시작부터 계속하기

Capgo를 사용 중이라면 시작하기 API 대시보드와 연산을 계획하는 데 사용하는 경우 API를 capgo/@capacitor-업로더를 사용하여 capgo/@capacitor-업로더의 원시 기능을 사용하는 경우 API 개요 API 개요의 구현 세부 정보를 위해 소개 소개의 구현 세부 정보를 위해 API 키 API 키의 구현 세부 정보를 위해 __CAPGO_KEEP_0__ __CAPGO_KEEP_1__