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
|
|
|
|
2020-02-26 18:34:45 +01:00
|
|
|
module.exports = async strapi => {
|
2018-02-21 17:18:33 +01:00
|
|
|
// set plugin store
|
2020-02-26 18:34:45 +01:00
|
|
|
const configurator = strapi.store({
|
2018-02-20 15:57:34 +01:00
|
|
|
type: 'plugin',
|
2019-04-05 16:11:09 +02:00
|
|
|
name: 'upload',
|
2020-02-26 18:34:45 +01:00
|
|
|
key: 'settings',
|
2018-02-20 15:57:34 +01:00
|
|
|
});
|
|
|
|
|
2020-02-26 18:34:45 +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)) {
|
2019-05-03 14:41:09 +02:00
|
|
|
strapi.plugins.upload.config.providers.push(require(installedProvider));
|
2019-04-05 16:11:09 +02:00
|
|
|
}
|
2019-03-01 17:09:19 +01:00
|
|
|
|
2019-08-12 15:35:40 +02:00
|
|
|
// if provider config does not exist set one by default
|
2020-02-26 18:34:45 +01:00
|
|
|
const config = await configurator.get();
|
2019-08-12 15:35:40 +02:00
|
|
|
|
|
|
|
if (!config) {
|
2020-02-26 18:34:45 +01:00
|
|
|
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
|
|
|
};
|