Merge branch 'features/single-types' into single-types/uid-ctm

This commit is contained in:
HichamELBSI 2020-02-26 14:56:27 +01:00
commit e8b9017219
5 changed files with 66 additions and 67 deletions

View File

@ -4,6 +4,8 @@
The context object (`ctx`) contains all the requests related information. They are accessible through `ctx.request`, from [controllers](controllers.md) and [policies](policies.md).
Strapi passes the `body` on `ctx.request.body` and `files` through `ctx.request.files`
For more information, please refer to the [Koa request documentation](http://koajs.com/#request).
## Responses

View File

@ -22,11 +22,11 @@
"@babel/preset-env": "^7.4.3",
"@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.4.3",
"@buffetjs/core": "2.1.1-next.1",
"@buffetjs/custom": "2.1.1-next.1",
"@buffetjs/hooks": "2.1.1-next.1",
"@buffetjs/icons": "2.1.1-next.1",
"@buffetjs/styles": "2.1.1-next.1",
"@buffetjs/core": "3.0.0-next.1",
"@buffetjs/custom": "3.0.0-next.1",
"@buffetjs/hooks": "3.0.0-next.1",
"@buffetjs/icons": "3.0.0-next.1",
"@buffetjs/styles": "3.0.0-next.1",
"@buffetjs/utils": "^2.0.0",
"@fortawesome/fontawesome-free": "^5.11.2",
"@fortawesome/fontawesome-svg-core": "^1.2.25",

View File

@ -13,13 +13,7 @@ module.exports = {
const uploadService = strapi.plugins.upload.services.upload;
// Retrieve provider configuration.
const config = await strapi
.store({
environment: strapi.config.environment,
type: 'plugin',
name: 'upload',
})
.get({ key: 'provider' });
const config = await uploadService.getConfig();
// Verify if the file upload is enable.
if (config.enabled === false) {
@ -105,12 +99,10 @@ module.exports = {
},
async getEnvironments(ctx) {
const environments = Object.keys(strapi.config.environments).map(
environment => ({
name: environment,
active: strapi.config.environment === environment,
})
);
const environments = Object.keys(strapi.config.environments).map(environment => ({
name: environment,
active: strapi.config.environment === environment,
}));
ctx.send({ environments });
},
@ -131,30 +123,32 @@ module.exports = {
},
async updateSettings(ctx) {
const {
request: { body: newSettings },
} = ctx;
await strapi
.store({
environment: ctx.params.environment,
type: 'plugin',
name: 'upload',
})
.set({ key: 'provider', value: ctx.request.body });
.set({
key: 'provider',
value: { ...newSettings, sizeLimit: parseFloat(newSettings.sizeLimit) },
});
ctx.send({ ok: true });
},
async find(ctx) {
const data = await strapi.plugins['upload'].services.upload.fetchAll(
ctx.query
);
const data = await strapi.plugins['upload'].services.upload.fetchAll(ctx.query);
// Send 200 `ok`
ctx.send(data);
},
async findOne(ctx) {
const data = await strapi.plugins['upload'].services.upload.fetch(
ctx.params
);
const data = await strapi.plugins['upload'].services.upload.fetch(ctx.params);
if (!data) {
return ctx.notFound('file.notFound');
@ -164,9 +158,7 @@ module.exports = {
},
async count(ctx) {
const data = await strapi.plugins['upload'].services.upload.count(
ctx.query
);
const data = await strapi.plugins['upload'].services.upload.count(ctx.query);
ctx.send({ count: data });
},
@ -208,10 +200,9 @@ const searchQueries = {
return ({ id }) => {
return model
.query(qb => {
qb.whereRaw('LOWER(hash) LIKE ?', [`%${id}%`]).orWhereRaw(
'LOWER(name) LIKE ?',
[`%${id}%`]
);
qb.whereRaw('LOWER(hash) LIKE ?', [`%${id}%`]).orWhereRaw('LOWER(name) LIKE ?', [
`%${id}%`,
]);
})
.fetchAll()
.then(results => results.toJSON());

View File

@ -33,9 +33,7 @@ module.exports = {
const createBuffer = async stream => {
const parts = await toArray(fs.createReadStream(stream.path));
const buffers = parts.map(part =>
_.isBuffer(part) ? part : Buffer.from(part)
);
const buffers = parts.map(part => (_.isBuffer(part) ? part : Buffer.from(part)));
const buffer = Buffer.concat(buffers);
@ -44,10 +42,7 @@ module.exports = {
name: stream.name,
sha256: niceHash(buffer),
hash: uuid().replace(/-/g, ''),
ext:
stream.name.split('.').length > 1
? `.${_.last(stream.name.split('.'))}`
: '',
ext: stream.name.split('.').length > 1 ? `.${_.last(stream.name.split('.'))}` : '',
buffer,
mime: stream.type,
size: (stream.size / 1000).toFixed(2),
@ -176,4 +171,15 @@ module.exports = {
})
);
},
async getConfig() {
const config = await strapi
.store({
environment: strapi.config.environment,
type: 'plugin',
name: 'upload',
})
.get({ key: 'provider' });
return { ...config, sizeLimit: parseFloat(config.sizeLimit) };
},
};

View File

@ -842,14 +842,14 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"
"@buffetjs/core@2.1.1-next.1":
version "2.1.1-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/core/-/core-2.1.1-next.1.tgz#1d1c880e57c82d3ffaad842ad9496d6ff2a686d0"
integrity sha512-B+wh5y0DsTNhEPeYz0qWb9UHkv67rl1kVNay/9voqQK0BxgQxAubh0+2rTmyVkinHpHpstcyRGuXBLzTqqctlA==
"@buffetjs/core@3.0.0-next.1":
version "3.0.0-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/core/-/core-3.0.0-next.1.tgz#e0e1cac708b976655028e8ff666c42fb47d6cc17"
integrity sha512-lgfQ/4MRxnUYl2e+Ewrihog5u4Y+2j97ZT7ZJ+mKpm8YyJoAvrzTpCEpMVBXjub/LfzLiSyfiIdpxJLOGzcCcQ==
dependencies:
"@buffetjs/hooks" "2.1.1-next.1"
"@buffetjs/icons" "2.1.1-next.1"
"@buffetjs/styles" "2.1.1-next.1"
"@buffetjs/hooks" "3.0.0-next.1"
"@buffetjs/icons" "3.0.0-next.1"
"@buffetjs/styles" "3.0.0-next.1"
"@buffetjs/utils" "2.0.0"
"@fortawesome/fontawesome-svg-core" "^1.2.25"
"@fortawesome/free-regular-svg-icons" "^5.11.2"
@ -861,31 +861,31 @@
react-dates "^21.5.1"
react-moment-proptypes "^1.7.0"
"@buffetjs/custom@2.1.1-next.1":
version "2.1.1-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/custom/-/custom-2.1.1-next.1.tgz#c6763e3129ab9b61d853ef3d99055e430ccc692c"
integrity sha512-jaRhgxTGN4vTswZNXTqcy6lioCfLn5mvZCfrZNdAqRGsqkm2QR6DLKm9GCZm5DgWfeLfMnwYnn63kPOKPSoSrg==
"@buffetjs/custom@3.0.0-next.1":
version "3.0.0-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/custom/-/custom-3.0.0-next.1.tgz#59c5c2ee1ce25de0069d4b7bcd87953abc046f44"
integrity sha512-nEWAd4lfo18WZov3G04asrw2SO86UM35efXP7xZMNBaom2VH34zIsfq4d7KtUbQ+CfNO0pui6XPPpCnDbXg+5g==
dependencies:
"@buffetjs/core" "2.1.1-next.1"
"@buffetjs/styles" "2.1.1-next.1"
"@buffetjs/core" "3.0.0-next.1"
"@buffetjs/styles" "3.0.0-next.1"
"@buffetjs/utils" "2.0.0"
moment "^2.24.0"
react-moment-proptypes "^1.7.0"
"@buffetjs/hooks@2.1.1-next.1":
version "2.1.1-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/hooks/-/hooks-2.1.1-next.1.tgz#2385698bd30b84b699dce9f3124cb09c64534903"
integrity sha512-WsJ300cfK/b/jmFp8ZBz0c4q+0s5Vd1z8kq6PUk+rYeZfLtX9Fhla/W3WxayMvZ5dJPr/r1st3sKyKUl1HpMvg==
"@buffetjs/hooks@3.0.0-next.1":
version "3.0.0-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/hooks/-/hooks-3.0.0-next.1.tgz#9a274d034c285f02eaf6794568db29ac06a01f53"
integrity sha512-iujDzVEVNP0aYyba7n+awx6rBn2IaEN4Sz/Mv30zAIVOJCJd6hnMoMhNKKjpHNLLTpkJ+yZaS15IKODK1SfhFw==
"@buffetjs/icons@2.1.1-next.1":
version "2.1.1-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/icons/-/icons-2.1.1-next.1.tgz#cd44a1571a4f42b1474d347581af2053e9151fa6"
integrity sha512-TfFE60MKzKIaToFb97yNluo1uib2jLY3uFr06XFlJ5f/6RM36gucnNHRUpsHoomNBpRf6wVARlINBveXuaaSwg==
"@buffetjs/icons@3.0.0-next.1":
version "3.0.0-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/icons/-/icons-3.0.0-next.1.tgz#3d4f787275951736f4e6f3a1bd5c56737bc0bd44"
integrity sha512-N1K9nMF4fw3xMWaK7JDQSU5BpOH+h1tePSIPNGoa9B6YKzyicBT4MWG4E0NvgFyiZ3+3aUn93ct9X0PDKqHGtg==
"@buffetjs/styles@2.1.1-next.1":
version "2.1.1-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/styles/-/styles-2.1.1-next.1.tgz#95e50076b4226eb372e9a95feca8b350b50a133f"
integrity sha512-WfLyDIum2mNM0XjbWM8uUMcX2JEfUJAWw/idy27F5HMTYSBN4BUalwDHWyWqytC65cDoqZ+X/2m3mCl5v2aDug==
"@buffetjs/styles@3.0.0-next.1":
version "3.0.0-next.1"
resolved "https://registry.yarnpkg.com/@buffetjs/styles/-/styles-3.0.0-next.1.tgz#d390a21bb170f058e291f27c9841bc3ffab84f46"
integrity sha512-Ug6iHUQHmMd4wYtL3dmz633tAHdm2A6JnqISrWLXRrSdV2zVGY+EVXBez/QPeEN+cR0xQUKXXJM6dnR4aDv1RA==
dependencies:
"@fortawesome/fontawesome-free" "^5.12.0"
"@fortawesome/fontawesome-svg-core" "^1.2.22"
@ -6667,9 +6667,9 @@ ejs@^2.6.1:
integrity sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==
electron-to-chromium@^1.3.349:
version "1.3.361"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.361.tgz#a820bf52da171c0024314745462cfe0dc944373e"
integrity sha512-OzSVjWpsRhJyr9PSAXkeloSe6e9viU2ToGt1wXlXFsGcxuI9vlsnalL+V/AM59Z2pEo3wRxIddtOGsT7Y6x/sQ==
version "1.3.360"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.360.tgz#1db9cb8d43f4c772546d94ea9be8b677a8ecb483"
integrity sha512-RE1pv2sjQiDRRN1nI0fJ0eQHZ9le4oobu16OArnwEUV5ycAU5SNjFyvzjZ1gPUAqBa2Ud1XagtW8j3ZXfHuQHA==
elegant-spinner@^1.0.1:
version "1.0.1"