@ginstone/nga-api
Version:
30 lines (29 loc) • 1.18 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UploadParam = void 0;
class UploadParam {
constructor(auth, fid, description, file, position) {
this.auth = auth;
this.fid = fid;
this.file = file;
this.description = description;
this.position = position;
}
build() {
let formData = new FormData();
formData.append("auth", this.auth);
formData.append("fid", "" + this.fid);
formData.append("attachment_file0_dscp", this.description);
formData.append("attachment_file0_img", "0");
// 是否自动转换尺寸(压缩图片,超过4M的图片如果不压缩会报错)
formData.append("attachment_file0_auto_size", this.file.size > 4 * 1024 * 1024 ? "1" : "0");
// 附件文件UTF8编码文件原名再urlencode
formData.append("attachment_file0_url_utf8_name", encodeURI(this.file.name));
formData.append("attachment_file0", this.file);
if (this.position) {
formData.append("attachment_file0_watermark", this.position);
}
return formData;
}
}
exports.UploadParam = UploadParam;