@jrmc/adonis-attachment 4.0.0-beta.2 → 4.0.0-beta.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.
|
@@ -39,8 +39,8 @@ export class AttachmentManager {
|
|
|
39
39
|
async createFromFile(input) {
|
|
40
40
|
const attributes = {
|
|
41
41
|
originalName: input.clientName,
|
|
42
|
-
extname: input.extname,
|
|
43
|
-
mimeType: `${input.type}/${input.subtype}
|
|
42
|
+
extname: input.extname || '',
|
|
43
|
+
mimeType: input.type && input.subtype ? `${input.type}/${input.subtype}` : '',
|
|
44
44
|
size: input.size,
|
|
45
45
|
};
|
|
46
46
|
if (!input.tmpPath) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import logger from '@adonisjs/core/services/logger';
|
|
1
2
|
import attachmentManager from '../../services/main.js';
|
|
2
3
|
import { defaultStateAttributeMixin } from '../utils/default_values.js';
|
|
3
4
|
import { Attachment } from '../attachments/attachment.js';
|
|
@@ -111,19 +112,22 @@ export default class RecordWithAttachment {
|
|
|
111
112
|
attachmentManager.queue.push({
|
|
112
113
|
name: `${this.#row.constructor.name}-${name}`,
|
|
113
114
|
async run() {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
await converterManager.run();
|
|
121
|
-
}
|
|
122
|
-
catch (err) {
|
|
123
|
-
throw new E_CANNOT_CREATE_VARIANT([err.message]);
|
|
124
|
-
}
|
|
115
|
+
const converterManager = new ConverterManager({
|
|
116
|
+
record,
|
|
117
|
+
attributeName: name,
|
|
118
|
+
options: record.#getOptionsByAttributeName(name),
|
|
119
|
+
});
|
|
120
|
+
await converterManager.run();
|
|
125
121
|
},
|
|
126
|
-
})
|
|
122
|
+
})
|
|
123
|
+
.onError = function (error) {
|
|
124
|
+
if (error.message) {
|
|
125
|
+
logger.error(error.message);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
throw new E_CANNOT_CREATE_VARIANT([error]);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
127
131
|
}
|
|
128
132
|
}
|
|
129
133
|
async regenerateVariants(options = {}) {
|
|
@@ -139,22 +143,25 @@ export default class RecordWithAttachment {
|
|
|
139
143
|
attachmentManager.queue.push({
|
|
140
144
|
name: `${this.#row.constructor.name}-${name}`,
|
|
141
145
|
async run() {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
await converterManager.run();
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
throw new E_CANNOT_CREATE_VARIANT([err.message]);
|
|
155
|
-
}
|
|
146
|
+
const converterManager = new ConverterManager({
|
|
147
|
+
record,
|
|
148
|
+
attributeName: name,
|
|
149
|
+
options: record.#getOptionsByAttributeName(name),
|
|
150
|
+
filters: {
|
|
151
|
+
variants: options.variants
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
await converterManager.run();
|
|
156
155
|
},
|
|
157
|
-
})
|
|
156
|
+
})
|
|
157
|
+
.onError = function (error) {
|
|
158
|
+
if (error.message) {
|
|
159
|
+
logger.error(error.message);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
throw new E_CANNOT_CREATE_VARIANT([error]);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
158
165
|
}
|
|
159
166
|
}
|
|
160
167
|
async detach() {
|