@itutoring/itutoring_application_js_api 1.24.2 → 1.24.4

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 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.GetApiFileFromObject(data);
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.GetApiFileFromObject(value);
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
- static GetApiFileFromObject(data)
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
- fileAttributes[key] = value.File;
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
 
@@ -13,9 +13,34 @@
13
13
  */
14
14
  export default class ApiFile
15
15
  {
16
+
17
+ /**
18
+ *
19
+ * @param {FileList} files
20
+ */
21
+ constructor(files)
22
+ {
23
+ if (files instanceof FileList)
24
+ {
25
+ if (files.length > 0)
26
+ {
27
+ this.File = files[0];
28
+ let current = this;
29
+ for (let i = 1; i < files.length; i++)
30
+ {
31
+ current.next = new ApiFile(files[i]);
32
+ current = current.next;
33
+ }
34
+ }
35
+ }
36
+ }
16
37
  /**
17
38
  * File object from input type=file
18
39
  * @type {File}
19
40
  */
20
41
  File;
42
+ /**
43
+ * Linked list, next file or null
44
+ */
45
+ next = null;
21
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itutoring/itutoring_application_js_api",
3
- "version": "1.24.2",
3
+ "version": "1.24.4",
4
4
  "description": "Javascript API for iTutoring Application",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",