你好,
我在主题中添加了一个自定义字段来上传文件。我想在点击创建主题/保存编辑按钮时上传文件。使用 /uploads.json API 文件正在成功上传,但不知何故我无法将数据更新到数据库中。
我使用了下面的代码:
api.modifyClass(“service:composer”, {
save() { const model = this.get('model'); if (model.action === 'createTopic' || (model.action === 'edit')) { const fileInput = document.getElementById('fileUpload'); const file = fileInput.files[0]; if (file) { uploadImage(file).then(url => { // Set the custom field value model.set('topic_file_upload', url); this._super(...arguments); }).catch(error => { console.log('error', error); }); } } }, });
我在这里遗漏了什么?有人能帮帮我吗?
谢谢!