@itutoring/itutoring_application_js_api 1.24.2 → 1.24.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.
- package/apiController.js +17 -5
- package/objects/ApiFile.js +4 -0
- package/package.json +1 -1
package/apiController.js
CHANGED
|
@@ -297,7 +297,7 @@ class APIController
|
|
|
297
297
|
{
|
|
298
298
|
let formData = new FormData();
|
|
299
299
|
// Extract ApiFiles from data and add them to formData
|
|
300
|
-
const files = this.
|
|
300
|
+
const files = this.ExtractApiFileFromObject(data);
|
|
301
301
|
Object.entries(files).forEach(([key, value]) =>
|
|
302
302
|
{
|
|
303
303
|
formData.append(key, value);
|
|
@@ -308,11 +308,10 @@ class APIController
|
|
|
308
308
|
{
|
|
309
309
|
if (typeof value === "object" && !(value instanceof File) && !(value instanceof ApiFile))
|
|
310
310
|
{
|
|
311
|
-
const files = this.
|
|
311
|
+
const files = this.ExtractApiFileFromObject(value);
|
|
312
312
|
Object.entries(files).forEach(([fKey, fValue]) =>
|
|
313
313
|
{
|
|
314
314
|
formData.append(fKey, fValue);
|
|
315
|
-
delete value[fKey];
|
|
316
315
|
});
|
|
317
316
|
|
|
318
317
|
let jsonVal = JSON.stringify(value);
|
|
@@ -323,14 +322,27 @@ class APIController
|
|
|
323
322
|
return formData;
|
|
324
323
|
}
|
|
325
324
|
|
|
326
|
-
|
|
325
|
+
/**
|
|
326
|
+
* Will remove original ApiFile objects from data and return them as key.
|
|
327
|
+
* @param {*} data
|
|
328
|
+
* @returns
|
|
329
|
+
*/
|
|
330
|
+
static ExtractApiFileFromObject(data)
|
|
327
331
|
{
|
|
328
332
|
let fileAttributes = {};
|
|
329
333
|
Object.entries(data).forEach(([key, value]) =>
|
|
330
334
|
{
|
|
331
335
|
if (typeof value === "object" && value instanceof ApiFile)
|
|
332
336
|
{
|
|
333
|
-
|
|
337
|
+
let index = 0;
|
|
338
|
+
var file = value.File
|
|
339
|
+
while (file != null)
|
|
340
|
+
{
|
|
341
|
+
fileAttributes[key + "_" + index] = file;
|
|
342
|
+
file = file.next;
|
|
343
|
+
index++;
|
|
344
|
+
}
|
|
345
|
+
delete data[key];
|
|
334
346
|
}
|
|
335
347
|
});
|
|
336
348
|
|
package/objects/ApiFile.js
CHANGED