@driveflux/upload 3.0.14 → 3.0.15
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.
- package/dist/uppy.js +377 -139
- package/package.json +6 -6
package/dist/uppy.js
CHANGED
|
@@ -1,3 +1,183 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _define_property(obj, key, value) {
|
|
31
|
+
if (key in obj) {
|
|
32
|
+
Object.defineProperty(obj, key, {
|
|
33
|
+
value: value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
obj[key] = value;
|
|
40
|
+
}
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
function _object_spread(target) {
|
|
44
|
+
for(var i = 1; i < arguments.length; i++){
|
|
45
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
+
var ownKeys = Object.keys(source);
|
|
47
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
ownKeys.forEach(function(key) {
|
|
53
|
+
_define_property(target, key, source[key]);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
function ownKeys(object, enumerableOnly) {
|
|
59
|
+
var keys = Object.keys(object);
|
|
60
|
+
if (Object.getOwnPropertySymbols) {
|
|
61
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
+
if (enumerableOnly) {
|
|
63
|
+
symbols = symbols.filter(function(sym) {
|
|
64
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
keys.push.apply(keys, symbols);
|
|
68
|
+
}
|
|
69
|
+
return keys;
|
|
70
|
+
}
|
|
71
|
+
function _object_spread_props(target, source) {
|
|
72
|
+
source = source != null ? source : {};
|
|
73
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
74
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
75
|
+
} else {
|
|
76
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
77
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return target;
|
|
81
|
+
}
|
|
82
|
+
function _ts_generator(thisArg, body) {
|
|
83
|
+
var f, y, t, _ = {
|
|
84
|
+
label: 0,
|
|
85
|
+
sent: function() {
|
|
86
|
+
if (t[0] & 1) throw t[1];
|
|
87
|
+
return t[1];
|
|
88
|
+
},
|
|
89
|
+
trys: [],
|
|
90
|
+
ops: []
|
|
91
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
92
|
+
return d(g, "next", {
|
|
93
|
+
value: verb(0)
|
|
94
|
+
}), d(g, "throw", {
|
|
95
|
+
value: verb(1)
|
|
96
|
+
}), d(g, "return", {
|
|
97
|
+
value: verb(2)
|
|
98
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
99
|
+
value: function() {
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
}), g;
|
|
103
|
+
function verb(n) {
|
|
104
|
+
return function(v) {
|
|
105
|
+
return step([
|
|
106
|
+
n,
|
|
107
|
+
v
|
|
108
|
+
]);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function step(op) {
|
|
112
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
113
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
114
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
115
|
+
if (y = 0, t) op = [
|
|
116
|
+
op[0] & 2,
|
|
117
|
+
t.value
|
|
118
|
+
];
|
|
119
|
+
switch(op[0]){
|
|
120
|
+
case 0:
|
|
121
|
+
case 1:
|
|
122
|
+
t = op;
|
|
123
|
+
break;
|
|
124
|
+
case 4:
|
|
125
|
+
_.label++;
|
|
126
|
+
return {
|
|
127
|
+
value: op[1],
|
|
128
|
+
done: false
|
|
129
|
+
};
|
|
130
|
+
case 5:
|
|
131
|
+
_.label++;
|
|
132
|
+
y = op[1];
|
|
133
|
+
op = [
|
|
134
|
+
0
|
|
135
|
+
];
|
|
136
|
+
continue;
|
|
137
|
+
case 7:
|
|
138
|
+
op = _.ops.pop();
|
|
139
|
+
_.trys.pop();
|
|
140
|
+
continue;
|
|
141
|
+
default:
|
|
142
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
143
|
+
_ = 0;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
147
|
+
_.label = op[1];
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
151
|
+
_.label = t[1];
|
|
152
|
+
t = op;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
if (t && _.label < t[2]) {
|
|
156
|
+
_.label = t[2];
|
|
157
|
+
_.ops.push(op);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
if (t[2]) _.ops.pop();
|
|
161
|
+
_.trys.pop();
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
op = body.call(thisArg, _);
|
|
165
|
+
} catch (e) {
|
|
166
|
+
op = [
|
|
167
|
+
6,
|
|
168
|
+
e
|
|
169
|
+
];
|
|
170
|
+
y = 0;
|
|
171
|
+
} finally{
|
|
172
|
+
f = t = 0;
|
|
173
|
+
}
|
|
174
|
+
if (op[0] & 5) throw op[1];
|
|
175
|
+
return {
|
|
176
|
+
value: op[0] ? op[1] : void 0,
|
|
177
|
+
done: true
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
1
181
|
import { config } from '@driveflux/config/frontend';
|
|
2
182
|
import { enhancedFetch } from '@driveflux/fetch';
|
|
3
183
|
import { useToastResult } from '@driveflux/ui/toast';
|
|
@@ -5,159 +185,202 @@ import AwsS3Multipart from '@uppy/aws-s3';
|
|
|
5
185
|
import Uppy from '@uppy/core';
|
|
6
186
|
import isEqual from 'lodash/isEqual.js';
|
|
7
187
|
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
8
|
-
|
|
188
|
+
var defaultOptions = {
|
|
9
189
|
autoProceed: true,
|
|
10
190
|
restrictions: {
|
|
11
|
-
maxFileSize: 10000000,
|
|
12
|
-
maxTotalFileSize: 100000000,
|
|
191
|
+
maxFileSize: 10000000,
|
|
192
|
+
maxTotalFileSize: 100000000,
|
|
13
193
|
maxNumberOfFiles: 20,
|
|
14
|
-
allowedFileTypes: [
|
|
194
|
+
allowedFileTypes: [
|
|
195
|
+
'image/*',
|
|
196
|
+
'application/pdf'
|
|
197
|
+
],
|
|
15
198
|
minFileSize: 1000,
|
|
16
199
|
minNumberOfFiles: 1,
|
|
17
|
-
requiredMetaFields: []
|
|
200
|
+
requiredMetaFields: []
|
|
18
201
|
},
|
|
19
|
-
getUploadParameters: null,
|
|
20
|
-
realm: null
|
|
202
|
+
getUploadParameters: null,
|
|
203
|
+
realm: null
|
|
21
204
|
};
|
|
22
|
-
|
|
23
|
-
|
|
205
|
+
var initUppy = function initUppy(uppyOptions, s3PluginOptions) {
|
|
206
|
+
var uppy = new Uppy(uppyOptions);
|
|
24
207
|
// @ts-expect-error
|
|
25
208
|
uppy.use(AwsS3Multipart, s3PluginOptions);
|
|
26
209
|
return uppy;
|
|
27
210
|
};
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
...defaultOptions,
|
|
37
|
-
...options,
|
|
38
|
-
restrictions: {
|
|
39
|
-
...defaultOptions.restrictions,
|
|
40
|
-
...options.restrictions,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
211
|
+
export var useUppy = function useUppy(options, isUnauthenticated) {
|
|
212
|
+
var previousOptions = useRef(_object_spread_props(_object_spread({}, defaultOptions, options), {
|
|
213
|
+
restrictions: defaultOptions.restrictions
|
|
214
|
+
}));
|
|
215
|
+
var finalOptions = useMemo(function() {
|
|
216
|
+
var newOptions = _object_spread_props(_object_spread({}, defaultOptions, options), {
|
|
217
|
+
restrictions: _object_spread({}, defaultOptions.restrictions, options.restrictions)
|
|
218
|
+
});
|
|
43
219
|
if (isEqual(newOptions, previousOptions.current)) {
|
|
44
220
|
return previousOptions.current;
|
|
45
221
|
}
|
|
46
222
|
previousOptions.current = newOptions;
|
|
47
223
|
return newOptions;
|
|
48
|
-
}, [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
224
|
+
}, [
|
|
225
|
+
options
|
|
226
|
+
]);
|
|
227
|
+
var _finalOptions_autoProceed = finalOptions.autoProceed, autoProceed = _finalOptions_autoProceed === void 0 ? true : _finalOptions_autoProceed, restrictions = finalOptions.restrictions, getUploadParameters = finalOptions.getUploadParameters, onUploadSuccess = finalOptions.onUploadSuccess, onComplete = finalOptions.onComplete, prefixFile = finalOptions.prefixFile, onError = finalOptions.onError, realm = finalOptions.realm;
|
|
228
|
+
var uploadUrlsMap = useRef(new Map());
|
|
229
|
+
var publicAcl = typeof options.publicAcl === 'boolean' ? options.publicAcl : realm === 'site';
|
|
230
|
+
var _useToastResult = useToastResult(), toastResult = _useToastResult.toastResult, toastError = _useToastResult.toastError;
|
|
231
|
+
var uppyOptions = useMemo(function() {
|
|
232
|
+
return {
|
|
233
|
+
autoProceed: autoProceed,
|
|
234
|
+
restrictions: restrictions
|
|
235
|
+
};
|
|
236
|
+
}, [
|
|
56
237
|
autoProceed,
|
|
57
|
-
restrictions
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
238
|
+
restrictions
|
|
239
|
+
]);
|
|
240
|
+
var s3PluginOptions = useMemo(function() {
|
|
241
|
+
return {
|
|
242
|
+
id: 'AwsS3',
|
|
243
|
+
getUploadParameters: function getUploadParameters1(file) {
|
|
244
|
+
return _async_to_generator(function() {
|
|
245
|
+
var parts, prefix, filename, targetUrl, body, response, url;
|
|
246
|
+
return _ts_generator(this, function(_state) {
|
|
247
|
+
switch(_state.label){
|
|
248
|
+
case 0:
|
|
249
|
+
if (getUploadParameters) {
|
|
250
|
+
return [
|
|
251
|
+
2,
|
|
252
|
+
getUploadParameters(file)
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
if (!realm) {
|
|
256
|
+
toastError({
|
|
257
|
+
title: 'Error while uploading file',
|
|
258
|
+
description: 'No realm provided'
|
|
259
|
+
});
|
|
260
|
+
throw new Error('No realm provided');
|
|
261
|
+
}
|
|
262
|
+
if (!file.type) {
|
|
263
|
+
toastError({
|
|
264
|
+
title: 'Error while uploading file',
|
|
265
|
+
description: 'No file type provided'
|
|
266
|
+
});
|
|
267
|
+
throw new Error('No file type provided');
|
|
268
|
+
}
|
|
269
|
+
parts = [];
|
|
270
|
+
prefix = file.meta.prefix;
|
|
271
|
+
if (typeof prefix === 'string' && prefix.length) {
|
|
272
|
+
parts.push(prefix.replace(/\/$/, ''));
|
|
273
|
+
}
|
|
274
|
+
parts.push(file.name || 'unknown');
|
|
275
|
+
filename = parts.join('/');
|
|
276
|
+
targetUrl = "".concat(config.apiUrl, "/files/").concat(isUnauthenticated ? 'unauthenticated-sign-upload' : 'sign-upload');
|
|
277
|
+
body = {
|
|
278
|
+
filename: filename,
|
|
279
|
+
contentType: file.type,
|
|
280
|
+
realm: realm,
|
|
281
|
+
publicAcl: publicAcl,
|
|
282
|
+
isUnauthenticated: isUnauthenticated
|
|
283
|
+
};
|
|
284
|
+
return [
|
|
285
|
+
4,
|
|
286
|
+
enhancedFetch(targetUrl, {
|
|
287
|
+
method: 'POST',
|
|
288
|
+
body: JSON.stringify(body)
|
|
289
|
+
})
|
|
290
|
+
];
|
|
291
|
+
case 1:
|
|
292
|
+
response = _state.sent();
|
|
293
|
+
if (response.err) {
|
|
294
|
+
toastResult(response, {
|
|
295
|
+
error: {
|
|
296
|
+
title: 'Error while uploading file',
|
|
297
|
+
description: response.val.message
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
throw new Error(response.val.message || 'Error while uploading file');
|
|
301
|
+
}
|
|
302
|
+
// We remove the query string from the url and store it in the uploadUrlsMap
|
|
303
|
+
// this is because uppy may not return the url in the upload success callback
|
|
304
|
+
url = response.val.url.split('?')[0];
|
|
305
|
+
uploadUrlsMap.current.set(file.id, url);
|
|
306
|
+
return [
|
|
307
|
+
2,
|
|
308
|
+
{
|
|
309
|
+
method: 'PUT',
|
|
310
|
+
url: response.val.url,
|
|
311
|
+
fields: {},
|
|
312
|
+
headers: {
|
|
313
|
+
'Content-Type': file.type
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
];
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
})();
|
|
106
320
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const url = response.val.url.split('?')[0];
|
|
110
|
-
uploadUrlsMap.current.set(file.id, url);
|
|
111
|
-
return {
|
|
112
|
-
method: 'PUT',
|
|
113
|
-
url: response.val.url,
|
|
114
|
-
fields: {},
|
|
115
|
-
headers: {
|
|
116
|
-
'Content-Type': file.type,
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
}), [
|
|
321
|
+
};
|
|
322
|
+
}, [
|
|
121
323
|
getUploadParameters,
|
|
122
324
|
realm,
|
|
123
325
|
toastResult,
|
|
124
326
|
toastError,
|
|
125
327
|
publicAcl,
|
|
126
|
-
isUnauthenticated
|
|
328
|
+
isUnauthenticated
|
|
127
329
|
]);
|
|
128
|
-
|
|
129
|
-
// @ts-expect-error options partial
|
|
330
|
+
var uppyInstance = useRef(// @ts-expect-error options partial
|
|
130
331
|
initUppy(uppyOptions, s3PluginOptions));
|
|
131
|
-
|
|
332
|
+
var uppy = uppyInstance.current;
|
|
132
333
|
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
334
|
+
var resyncMap = useCallback(function() {
|
|
335
|
+
var newMap = new Map();
|
|
336
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
337
|
+
try {
|
|
338
|
+
for(var _iterator = uppy.getFiles()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
339
|
+
var file = _step.value;
|
|
340
|
+
var oldUploadUrl = uploadUrlsMap.current.get(file.id);
|
|
341
|
+
if (oldUploadUrl) {
|
|
342
|
+
newMap.set(file.id, oldUploadUrl);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
} catch (err) {
|
|
346
|
+
_didIteratorError = true;
|
|
347
|
+
_iteratorError = err;
|
|
348
|
+
} finally{
|
|
349
|
+
try {
|
|
350
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
351
|
+
_iterator.return();
|
|
352
|
+
}
|
|
353
|
+
} finally{
|
|
354
|
+
if (_didIteratorError) {
|
|
355
|
+
throw _iteratorError;
|
|
356
|
+
}
|
|
139
357
|
}
|
|
140
358
|
}
|
|
141
359
|
// Resync the map
|
|
142
360
|
uploadUrlsMap.current = newMap;
|
|
143
361
|
}, []);
|
|
144
362
|
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
145
|
-
useEffect(()
|
|
363
|
+
useEffect(function() {
|
|
364
|
+
var _uppy_getPlugin;
|
|
146
365
|
uppy.setOptions(uppyOptions);
|
|
147
|
-
uppy.getPlugin('AwsS3')
|
|
148
|
-
}, [
|
|
149
|
-
|
|
150
|
-
|
|
366
|
+
(_uppy_getPlugin = uppy.getPlugin('AwsS3')) === null || _uppy_getPlugin === void 0 ? void 0 : _uppy_getPlugin.setOptions(s3PluginOptions);
|
|
367
|
+
}, [
|
|
368
|
+
uppyOptions,
|
|
369
|
+
s3PluginOptions
|
|
370
|
+
]);
|
|
371
|
+
useEffect(function() {
|
|
372
|
+
var handleFileAdded = function handleFileAdded(file) {
|
|
151
373
|
resyncMap();
|
|
152
374
|
if (prefixFile) {
|
|
153
375
|
// @ts-expect-error
|
|
154
|
-
uppy.setMeta({
|
|
376
|
+
uppy.setMeta({
|
|
377
|
+
prefix: prefixFile(file)
|
|
378
|
+
});
|
|
155
379
|
}
|
|
156
380
|
};
|
|
157
381
|
uppy.on('file-added', handleFileAdded);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
(file ? uploadUrlsMap.current.get(file.id) : undefined);
|
|
382
|
+
var handleUploadSuccess = function handleUploadSuccess(file, response) {
|
|
383
|
+
var uploadURL = response.uploadURL || (file ? uploadUrlsMap.current.get(file.id) : undefined);
|
|
161
384
|
if (!response.uploadURL) {
|
|
162
385
|
response.uploadURL = uploadURL;
|
|
163
386
|
}
|
|
@@ -165,51 +388,67 @@ export const useUppy = (options, isUnauthenticated) => {
|
|
|
165
388
|
if (!uploadURL) {
|
|
166
389
|
toastError({
|
|
167
390
|
title: 'Error while uploading file',
|
|
168
|
-
description:
|
|
391
|
+
description: "The uploader didn't return a valid uploadURL for file ".concat(file === null || file === void 0 ? void 0 : file.name)
|
|
169
392
|
});
|
|
170
393
|
return;
|
|
171
394
|
}
|
|
172
|
-
onUploadSuccess(file, {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
});
|
|
395
|
+
onUploadSuccess(file, _object_spread_props(_object_spread({}, response), {
|
|
396
|
+
uploadURL: uploadURL
|
|
397
|
+
}));
|
|
176
398
|
}
|
|
177
399
|
};
|
|
178
400
|
uppy.on('upload-success', handleUploadSuccess);
|
|
179
|
-
|
|
180
|
-
|
|
401
|
+
var handleComplete = function handleComplete(result) {
|
|
402
|
+
var realUploaded = [];
|
|
181
403
|
if (!result.successful) {
|
|
182
404
|
return;
|
|
183
405
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
406
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
407
|
+
try {
|
|
408
|
+
// Populate upload URL if any
|
|
409
|
+
for(var _iterator = result.successful[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
410
|
+
var uploaded = _step.value;
|
|
411
|
+
var _uploaded_response;
|
|
412
|
+
var uploadURL = ((_uploaded_response = uploaded.response) === null || _uploaded_response === void 0 ? void 0 : _uploaded_response.uploadURL) || uploadUrlsMap.current.get(uploaded.id);
|
|
413
|
+
if (!uploadURL) {
|
|
414
|
+
toastError({
|
|
415
|
+
title: 'Error while uploading file',
|
|
416
|
+
description: "The uploader didn't return a valid uploadURL for file ".concat(uploaded.name)
|
|
417
|
+
});
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
uploaded.response = _object_spread_props(_object_spread({}, uploaded.response), {
|
|
421
|
+
uploadURL: uploadURL
|
|
191
422
|
});
|
|
192
|
-
|
|
423
|
+
uploaded.uploadURL = uploadURL;
|
|
424
|
+
realUploaded.push(uploaded);
|
|
425
|
+
}
|
|
426
|
+
} catch (err) {
|
|
427
|
+
_didIteratorError = true;
|
|
428
|
+
_iteratorError = err;
|
|
429
|
+
} finally{
|
|
430
|
+
try {
|
|
431
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
432
|
+
_iterator.return();
|
|
433
|
+
}
|
|
434
|
+
} finally{
|
|
435
|
+
if (_didIteratorError) {
|
|
436
|
+
throw _iteratorError;
|
|
437
|
+
}
|
|
193
438
|
}
|
|
194
|
-
uploaded.response = {
|
|
195
|
-
...uploaded.response,
|
|
196
|
-
uploadURL,
|
|
197
|
-
};
|
|
198
|
-
uploaded.uploadURL = uploadURL;
|
|
199
|
-
realUploaded.push(uploaded);
|
|
200
439
|
}
|
|
201
440
|
if (onComplete) {
|
|
202
441
|
onComplete(realUploaded);
|
|
203
442
|
}
|
|
204
443
|
};
|
|
205
444
|
uppy.on('complete', handleComplete);
|
|
206
|
-
|
|
445
|
+
var handleError = function handleError(file, error, response) {
|
|
207
446
|
if (onError) {
|
|
208
447
|
onError(file, error, response);
|
|
209
448
|
}
|
|
210
449
|
};
|
|
211
450
|
uppy.on('upload-error', handleError);
|
|
212
|
-
return ()
|
|
451
|
+
return function() {
|
|
213
452
|
uppy.off('file-added', handleFileAdded);
|
|
214
453
|
uppy.off('upload-success', handleUploadSuccess);
|
|
215
454
|
uppy.off('complete', handleComplete);
|
|
@@ -222,8 +461,7 @@ export const useUppy = (options, isUnauthenticated) => {
|
|
|
222
461
|
onUploadSuccess,
|
|
223
462
|
resyncMap,
|
|
224
463
|
prefixFile,
|
|
225
|
-
toastError
|
|
464
|
+
toastError
|
|
226
465
|
]);
|
|
227
466
|
return uppy;
|
|
228
467
|
};
|
|
229
|
-
//# sourceMappingURL=uppy.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/upload",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@driveflux/config": "3.0.
|
|
16
|
-
"@driveflux/fetch": "8.0.
|
|
17
|
-
"@driveflux/ui": "3.0.
|
|
15
|
+
"@driveflux/config": "3.0.13",
|
|
16
|
+
"@driveflux/fetch": "8.0.4",
|
|
17
|
+
"@driveflux/ui": "3.0.6",
|
|
18
18
|
"@uppy/aws-s3": "^5.1.0",
|
|
19
19
|
"@uppy/core": "^5.2.0",
|
|
20
20
|
"lodash": "^4.18.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@driveflux/fab": "4.0.
|
|
23
|
+
"@driveflux/fab": "4.0.3",
|
|
24
24
|
"@driveflux/tsconfig": "3.0.2",
|
|
25
25
|
"@swc/cli": "^0.8.1",
|
|
26
|
-
"@swc/core": "^1.15.
|
|
26
|
+
"@swc/core": "^1.15.40",
|
|
27
27
|
"@types/lodash": "^4.17.24",
|
|
28
28
|
"@types/node": "^25.9.1",
|
|
29
29
|
"@types/react": "19.2.15",
|