I'm using loopback storage component "loopback-component-storage" to upload files. But problem is after adding this storage component and a Model for it named as Container, I'm not able to migrate models in my application to database.
Following is error what i get
Error: Cannot create data source "storage": Cannot initialize connector "loopback-component-storage": FileSystemProvider: Path does not exist: ./server/files
at new FileSystemProvider
But I've /server/files directory as well in project described through this snapshot
Following is datasources.json file
{
"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"
}
}
Following is model-config.json (partially, not full)
{
"_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
}
}
Following is Container (to upload/download files)
{
"name": "Container",
"plural": "containers",
"base": "Model",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
And following is my script to update model, say Address
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();
});
Can someone please help me in figuring out the problem, why storage component is throwing exception of that files directory doesn't exist
sudo npm start. Or make sure that your application has permissions to work with your storage folder. - Serg