48 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-02-20 15:57:34 +01:00
'use strict';
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
2018-04-30 18:00:01 +02:00
const _ = require('lodash');
2018-02-20 15:57:34 +01:00
module.exports = async strapi => {
2018-02-21 17:18:33 +01:00
// set plugin store
const configurator = strapi.store({
2018-02-20 15:57:34 +01:00
type: 'plugin',
2019-04-05 16:11:09 +02:00
name: 'upload',
key: 'settings',
2018-02-20 15:57:34 +01:00
});
Object.assign(strapi.plugins.upload.config, {
enabled: true,
provider: 'local',
sizeLimit: 1000000,
providers: [],
});
2018-03-07 11:26:53 +01:00
2019-05-06 16:01:18 +02:00
const installedProviders = Object.keys(strapi.config.info.dependencies)
2019-10-26 15:50:31 +02:00
.filter(d => d.includes('strapi-provider-upload-'))
2019-05-06 16:01:18 +02:00
.concat('strapi-provider-upload-local');
2018-02-20 15:57:34 +01:00
2019-05-06 16:01:18 +02:00
for (let installedProvider of _.uniq(installedProviders)) {
strapi.plugins.upload.config.providers.push(require(installedProvider));
2019-04-05 16:11:09 +02:00
}
2019-08-12 15:35:40 +02:00
// if provider config does not exist set one by default
const config = await configurator.get();
2019-08-12 15:35:40 +02:00
if (!config) {
await configurator.set({
value: {
sizeOptimization: true,
responsiveDimensions: true,
videoPreview: true,
},
2019-08-12 15:35:40 +02:00
});
2019-04-05 16:11:09 +02:00
}
2018-02-20 15:57:34 +01:00
};