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