我正在使用环回存储组件"loopback-component-storage"
来上传文件。但问题是在添加了这个存储组件和一个名为 Container 的模型后,我无法将应用程序中的模型迁移到数据库。
以下是我得到的错误
Error: Cannot create data source "storage": Cannot initialize connector "loopback-component-storage": FileSystemProvider: Path does not exist: ./server/files
at new FileSystemProvider
但是我在通过此快照描述的项目中 也有/server/files目录
以下是 datasources.json 文件
{
"school": {
"host": "127.0.0.1",
"port": 3306,
"url": "",
"database": "school_db",
"password": "root",
"name": "school",
"user": "root",
"connector": "mysql"
},
"storage": {
"name": "storage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./server/files"
}
}
以下是model-config.json
(部分,不完整)
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"Container": {
"dataSource": "storage",
"public": true
}
}
以下是容器(上传/下载文件)
{
"name": "Container",
"plural": "containers",
"base": "Model",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
以下是我更新模型的脚本,比如地址
var server = require('./../../server');
var ds = server.dataSources.school;
var tables = ['Address'];
ds.autoupdate(tables, function(er,result) {
if (er) throw er;
ds.discoverModelProperties('Address', function (err, props) {
console.log(props);
});
ds.disconnect();
});
有人可以帮我解决问题吗,为什么存储组件会抛出该文件目录不存在的异常