mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
Add possibility to pull file value
This commit is contained in:
parent
fd6e907fc7
commit
91bf22cbbd
@ -342,6 +342,35 @@ module.exports = function (strapi) {
|
||||
cb(null, obj);
|
||||
},
|
||||
|
||||
/**
|
||||
* Pull file from local server
|
||||
*
|
||||
* @param {Object} data
|
||||
*
|
||||
* @return {Function} cb
|
||||
*/
|
||||
|
||||
pullFile: function (data, cb) {
|
||||
const rootPath = path.resolve(data.path);
|
||||
|
||||
fs.exists(rootPath, function (exists) {
|
||||
if (exists) {
|
||||
fs.readFile(rootPath, 'utf8', function (err, data) {
|
||||
if (err) {
|
||||
cb('Impossible to read `' + rootPath + '`', null);
|
||||
} else {
|
||||
cb(null, {
|
||||
path: rootPath,
|
||||
value: JSON.parse(data)
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
cb('Unknow path `' + rootPath + '`', null);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Rebuild dictionary
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user