mirror of
https://github.com/strapi/strapi.git
synced 2025-11-16 10:07:55 +00:00
sign for multiple media attributes
This commit is contained in:
parent
5b92402129
commit
813eed2d9c
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { traverseEntity } = require('@strapi/utils');
|
const { mapAsync, traverseEntity } = require('@strapi/utils');
|
||||||
const { getService } = require('../../../utils');
|
const { getService } = require('../../../utils');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,10 +15,20 @@ const { getService } = require('../../../utils');
|
|||||||
const signEntityMediaVisitor = async ({ key, value, attribute }, { set }) => {
|
const signEntityMediaVisitor = async ({ key, value, attribute }, { set }) => {
|
||||||
const { signFileUrls } = getService('file');
|
const { signFileUrls } = getService('file');
|
||||||
|
|
||||||
if (value && attribute.type === 'media') {
|
if (!value || attribute.type !== 'media') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the attribute is repeatable sign each file
|
||||||
|
if (attribute.multiple) {
|
||||||
|
const signedFiles = await mapAsync(value, signFileUrls);
|
||||||
|
set(key, signedFiles);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the attribute is not repeatable only sign a single file
|
||||||
const signedFile = await signFileUrls(value);
|
const signedFile = await signFileUrls(value);
|
||||||
set(key, signedFile);
|
set(key, signedFile);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user