file(data: string | ArrayBuffer, name?: string, contentType?: string): File
Parameter | Type | Description |
data | string or ArrayBuffer. | Text content. |
name? | string | Optional; file name, defaults to timestamp in nanoseconds. |
contentType? | string | Optional; content type, defaults to application/octet-stream. |
Type | Description |
File object. |
import http from 'pts/http';const data = open('./sample/tmp.js');export default function () {const file = http.file(data);//@ts-ignore Ignore the verification.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 Ignore the verification.console.log(file.data.length); // 231console.log(file.name); // dataconsole.log(file.contentType); // application/json}