file(data: string | ArrayBuffer, name?: string, contentType?: string): File
参数 | 类型 | 描述 |
data | string 或 ArrayBuffer | 文件内容 |
name? | string | 可选,文件名,默认为纳秒级时间戳 |
contentType? | string | 可选,内容类型,默认为 application/octet-stream |
类型 | 描述 |
文件对象 |
import http from 'pts/http';const data = open('./sample/tmp.js');export default function () {const file = http.file(data);//@ts-ignore 忽略校验console.log(file.data.length); // 231console.log(file.name); // 1635403323707745000console.log(file.contentType); // application/octet-stream}
import http from 'pts/http';const data = open('./sample/tmp.js');export default function () {const file = http.file(data, 'data', 'application/json');//@ts-ignore 忽略校验console.log(file.data.length); // 231console.log(file.name); // dataconsole.log(file.contentType); // application/json}
文档反馈