@morpheus/addon-netext
라이브러리에서 제공되는 모듈
Before M.net.http.upload
HTTP를 통해 파일 또는 텍스트 데이터를 업로드합니다.
Parameters
options
Object
string
Record<string, string>
Record<string, any>
Array<{ name?: string, content: string, type: "FILE" | "TEXT" }>
string
boolean
number
(total: string, current: string, remaining: string, percentage: string) => void
Return
Promise<Object>
string | number
string
string
Usage
import { uploadHttp } from '@morpheus/addon-netext'
uploadHttp({
url: 'https://example.com/upload',
headers: {
Authorization: 'Bearer token'
},
parameters: {
userId: '12345'
},
body: [
{
name: 'file1',
content: 'file://path/to/file.jpg',
type: 'FILE'
}
],
progress: (total, current, remaining, percentage) => {
console.log(`진행률: ${percentage}%`);
}
}).then(result => {
console.log(result);
})
Before M.net.http.download
HTTP를 통해 파일을 다운로드합니다.
Parameters
options
Object
string
"GET"
| "POST"
| "PUT"
| "DELETE"
| string
Record<string, string>
Record<string, any>
string
string
"DEFAULT"
| string
number
string
boolean
boolean
(total: string, current: string, remaining: string, percentage: string) => void
Return
Promise<Object>
string | number
string
string
string
string
string
string
string
Usage
import { donwloadHttp } from '@morpheus/addon-netext'
donwloadHttp({
url: 'https://example.com/file.zip',
directory: 'downloads',
fileName: 'file.zip',
progress: (total, current, remaining, percentage) => {
console.log(`다운로드 진행률: ${percentage}%`);
}
}).then(result => {
if (result.status === 'SUCCESS') {
console.log('파일 다운로드 완료:', result.file);
} else {
console.error('다운로드 실패:', result.error);
}
})