@jrmc/adonis-attachment 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -42,8 +42,8 @@ export class AttachmentManager {
|
|
|
42
42
|
async createFromFile(input) {
|
|
43
43
|
const attributes = {
|
|
44
44
|
originalName: input.clientName,
|
|
45
|
-
extname: input.extname,
|
|
46
|
-
mimeType: `${input.type}/${input.subtype}
|
|
45
|
+
extname: input.extname || '',
|
|
46
|
+
mimeType: input.type && input.subtype ? `${input.type}/${input.subtype}` : '',
|
|
47
47
|
size: input.size,
|
|
48
48
|
};
|
|
49
49
|
if (!input.tmpPath) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
|
|
6
6
|
*/
|
|
7
|
+
import logger from '@adonisjs/core/services/logger';
|
|
7
8
|
import attachmentManager from '../../services/main.js';
|
|
8
9
|
import { getOptions } from './helpers.js';
|
|
9
10
|
import { ConverterManager } from '../converter_manager.js';
|
|
@@ -75,16 +76,19 @@ export async function generateVariants(modelInstance, attributeName) {
|
|
|
75
76
|
attachmentManager.queue.push({
|
|
76
77
|
name: `${modelInstance.constructor.name}-${attributeName}`,
|
|
77
78
|
async run() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
await converterManager.save();
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
throw new E_CANNOT_CREATE_VARIANT([err.message]);
|
|
87
|
-
}
|
|
79
|
+
const converterManager = new ConverterManager({
|
|
80
|
+
record: modelInstance,
|
|
81
|
+
attributeName,
|
|
82
|
+
});
|
|
83
|
+
await converterManager.save();
|
|
88
84
|
},
|
|
89
|
-
})
|
|
85
|
+
})
|
|
86
|
+
.onError = function (error) {
|
|
87
|
+
if (error.message) {
|
|
88
|
+
logger.error(error.message);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new E_CANNOT_CREATE_VARIANT([error]);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
90
94
|
}
|