This commit is contained in:
parent
edfa112874
commit
8d5aef4684
|
@ -69,12 +69,22 @@ module.exports = Self => {
|
||||||
if (!hasWriteRole)
|
if (!hasWriteRole)
|
||||||
throw new UserError(`You don't have enough privileges`);
|
throw new UserError(`You don't have enough privileges`);
|
||||||
|
|
||||||
|
// Create final folder if not exists
|
||||||
|
const dmsType = await models.DmsType.findById(args.dmsTypeId);
|
||||||
|
await models.Container.getContainer(dmsType.path).catch(async err => {
|
||||||
|
if (err.code === 'ENOENT') {
|
||||||
|
await models.Container.createContainer({
|
||||||
|
name: dmsType.path
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Upload file to temporary path
|
||||||
const uploaded = await models.Container.upload('temp', ctx.req, ctx.result, fileOptions);
|
const uploaded = await models.Container.upload('temp', ctx.req, ctx.result, fileOptions);
|
||||||
const files = Object.values(uploaded.files).map(file => {
|
const files = Object.values(uploaded.files).map(file => {
|
||||||
return file[0];
|
return file[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
const dmsType = await models.DmsType.findById(args.dmsTypeId);
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
|
|
Loading…
Reference in New Issue