我正在使用软件包ostrio:files
在我的应用中插入文件/图像。请在下面找到错误详细信息:
errorClass {message: "Match error: Expected plain object", path: "", sanitizedError: errorClass, errorType: "Match.Error", stack: "Error: Match error: Expected plain object↵ at e…082d0f2fc7a28f46b645fd80a32b5206ce5b72b2:3228:10)"
这是我的代码:服务器端
import { FilesCollection } from "meteor/ostrio:files";
export const Images = new FilesCollection({ collectionName: "Images" });
客户端:
import { Images } from "../../api/user_image";
import React from "react";
import { Meteor } from "meteor/meteor";
import { Images } from "../../api/user_image";
export default class Image extends React.Component {
constructor(props) {
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit(event) {
event.preventDefault();
let fsFile = new FS.File(event.target.files[0]);
fsFile.owner = Meteor.userId();
Images.insert(fsFile, function(err) {
if (err) throw err;
});
}
render() {
return (
<form onSubmit={this.handleSubmit.bind(this)}>
<input type="file" name="files" />
<button>Save</button>
</form>
);
}
}
有解决方法吗?使用流星在数据库中插入图像并做出反应的最佳方法是什么?