UNPKG

@larksuiteoapi/api

Version:
76 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.File = exports.FormData = void 0; const stream = require('stream'); class FormData { constructor() { this.params = new Map(); this.files = []; } setField(k, v) { this.params.set(k, v); return this; } addField(k, v) { this.params.set(k, v); return this; } addFile(k, file) { file.setFieldName(k); this.files.push(file); return this; } appendFile(file) { this.files.push(file); return this; } getParams() { return this.params; } getFiles() { return this.files; } } exports.FormData = FormData; class File { constructor() { this.fieldName = "file"; this.name = "unknown"; } getFieldName() { return this.fieldName; } setFieldName(fieldName) { this.fieldName = fieldName; return this; } setName(name) { this.name = name; return this; } getName() { return this.name; } setType(type) { this.type = type; return this; } getType() { return this.type; } setContent(content) { if (content instanceof stream.Readable) { this.stream = true; } this.content = content; return this; } getContent() { return this.content; } isStream() { return this.stream; } } exports.File = File; //# sourceMappingURL=formData.js.map