@cocreate/file 1.16.0 → 1.17.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [1.17.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.16.0...v1.17.0) (2024-03-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * descriptions ([fe2cffc](https://github.com/CoCreate-app/CoCreate-file/commit/fe2cffc731ba9ffecbe6c5768ae43e242d9dea92))
7
+
8
+
9
+ ### Features
10
+
11
+ * handle mediaSegmentation, define path ([4c8e478](https://github.com/CoCreate-app/CoCreate-file/commit/4c8e478bf7ff6a382c18bfbe7af60886af9e0d9e))
12
+
1
13
  # [1.16.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.15.2...v1.16.0) (2024-02-16)
2
14
 
3
15
 
package/README.md CHANGED
@@ -1,14 +1,21 @@
1
1
  # CoCreate-file
2
2
 
3
- This is a configurable headless file uploader that utilizes HTML5 attributes for easy customization. With this module, users can easily upload files to a server without requiring a formal UI or browser interaction. By leveraging HTML5 attributes, it's easy to customize and fine-tune the behavior of the uploader to fit specific needs. This uploader is perfect for developers looking to implement file uploads in a headless environment. Take it for a spin in our [playground!](https://cocreate.app/docs/file)
3
+ CoCreate-file is an advanced, configurable headless file uploader designed for comprehensive file management capabilities without a traditional user interface. Accessible via a JavaScript API and HTML5 attributes, it offers unparalleled flexibility in handling file operations on both local and server environments. Take it for a spin in our [playground!](https://cocreate.app/docs/file)
4
4
 
5
5
  ![minified](https://img.badgesize.io/https://cdn.cocreate.app/file/latest/CoCreate-file.min.js?style=flat-square&label=minified&color=orange)
6
6
  ![gzip](https://img.badgesize.io/https://cdn.cocreate.app/file/latest/CoCreate-file.min.js?compression=gzip&style=flat-square&label=gzip&color=yellow)
7
7
  ![brotli](https://img.badgesize.io/https://cdn.cocreate.app/file/latest/CoCreate-file.min.js?compression=brotli&style=flat-square&label=brotli)
8
- ![GitHub latest release](https://img.shields.io/github/v/release/CoCreate-app/CoCreate-action?style=flat-square)
9
- ![License](https://img.shields.io/github/license/CoCreate-app/CoCreate-action?style=flat-square)
8
+ ![GitHub latest release](https://img.shields.io/github/v/release/CoCreate-app/CoCreate-file?style=flat-square)
9
+ ![License](https://img.shields.io/github/license/CoCreate-app/CoCreate-file?style=flat-square)
10
10
  ![Hiring](https://img.shields.io/static/v1?style=flat-square&label=&message=Hiring&color=blueviolet)
11
11
 
12
+ ## Key Features
13
+
14
+ - **JavaScript API & HTML5 Customization**: Easily manage file uploads and operations through a powerful JavaScript API or by utilizing HTML5 attributes for easy integration and customization.
15
+ - **Local & Server File Operations**: Supports reading, writing, and uploading files both locally and to the server, catering to a wide range of application needs.
16
+ - **Graceful Fallbacks**: Implements graceful fallbacks to the standard HTML5 file input API, ensuring compatibility and functionality across different browsers and environments.
17
+ - **Headless File Management**: Designed for use in headless applications or scenarios where a UI is not required or desired, providing a clean, efficient backend solution for file management.
18
+
12
19
  ![CoCreate-file](https://cdn.cocreate.app/docs/CoCreate-file.gif)
13
20
 
14
21
  ## [Docs & Demo](https://cocreate.app/docs/file)
package/demo/index.html CHANGED
@@ -18,7 +18,7 @@
18
18
  </form>
19
19
 
20
20
  <form>
21
- <input type="file" />
21
+ <input type="file" path="/assets/test" />
22
22
  <button actions="upload">upload</button>
23
23
  </form>
24
24
 
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Video Segmenting | CoCreateJS</title>
5
+
6
+ <!-- CoCreate Favicon -->
7
+ <link
8
+ rel="icon"
9
+ type="image/png"
10
+ sizes="32x32"
11
+ href="../assets/favicon.ico" />
12
+ <link rel="manifest" href="/manifest.webmanifest" />
13
+ </head>
14
+ <body>
15
+ <input id="fileInput" type="file" accept="video/mp4" />
16
+
17
+ <script src="./video-segmenting.js"></script>
18
+ <!-- <script src="../dist/CoCreate-file.js"></script> -->
19
+ <!-- <script src="../../../CoCreateJS/dist/CoCreate.js"></script> -->
20
+ <!-- <script src="https://CoCreate.app/dist/CoCreate.js"></script> -->
21
+ </body>
22
+ </html>
package/package.json CHANGED
@@ -1,21 +1,26 @@
1
1
  {
2
2
  "name": "@cocreate/file",
3
- "version": "1.16.0",
4
- "description": "A headless file uploader that uses HTML5 attributes for customization. Allows easy upload of files to server.",
3
+ "version": "1.17.0",
4
+ "description": "A versatile, configurable headless file uploader supporting both local and server file operations. Accessible via a JavaScript API and HTML5 attributes, it offers seamless file reading, writing, and uploading capabilities with graceful fallbacks to the standard HTML5 file input API. Ideal for developers requiring robust file management in headless or UI-less environments.",
5
5
  "keywords": [
6
- "file",
6
+ "file uploader",
7
+ "headless",
8
+ "HTML5 attributes",
9
+ "server upload",
10
+ "customizable uploader",
11
+ "file upload API",
12
+ "no UI upload",
13
+ "background file upload",
14
+ "programmatic file upload",
15
+ "headless file management",
7
16
  "cocreate",
8
17
  "low-code-framework",
9
- "no-code-framework",
10
18
  "cocreatejs",
11
19
  "cocreatejs-component",
12
20
  "cocreate-framework",
13
- "no-code",
14
21
  "low-code",
15
- "collaborative-framework",
16
22
  "realtime",
17
23
  "realtime-framework",
18
- "collaboration",
19
24
  "shared-editing",
20
25
  "html5-framework",
21
26
  "javascript-framework"
package/src/client.js CHANGED
@@ -424,35 +424,80 @@ async function upload(element, data) {
424
424
 
425
425
  for (let input of inputs) {
426
426
  let Data = Elements.getObject(input);
427
- if (Data.type) {
428
- if (input.getFilter)
429
- Data.$filter = await input.getFilter()
427
+ let key = getAttribute('key')
428
+ if (Data.type === 'key')
429
+ Data.type = 'object'
430
430
 
431
- let files = await getFiles(input)
431
+ Data.method = Data.type + '.update'
432
+ if (Data.array)
433
+ Data.array = 'files'
432
434
 
433
- let key = getAttribute('key')
434
- if (Data.type === 'key')
435
- Data.type = 'object'
435
+ let path = input.getAttribute('path')
436
+ let directory = '/'
437
+
438
+ if (path) {
439
+ directory = path.split('/');
440
+ directory = directory[directory.length - 1];
441
+ if (!path.endswith('/'))
442
+ path += '/'
443
+ } else
444
+ path = directory = '/'
436
445
 
437
- let object = input.getAttribute('object')
438
- if (key) {
439
- Data[Data.type] = { _id: object, [key]: files }
440
- } else {
441
- Data[Data.type] = files
446
+ if (input.getFilter) {
447
+ Data.$filter = await input.getFilter()
448
+ if (!Data.$filter.query)
449
+ Data.$filter.query = {}
450
+ } else
451
+ Data.$filter = {
452
+ query: {}
442
453
  }
443
454
 
444
- Data.method = Data.type + '.update'
445
- let response = await Crud.send(Data)({
446
- array,
447
- object,
448
- upsert: true
449
- });
450
455
 
451
- data.push(response)
452
- if (response && (!object || object !== response.object)) {
453
- Elements.setTypeValue(element, response);
456
+ let files = await getFiles(input)
457
+ let segmentSize = 10 * 1024 * 1024
458
+ for (let i = 0; i < files.length; i++) {
459
+ files[i].path = path
460
+ files[i].pathname = path + '/' + files[i].name
461
+ files[i].directory = directory
462
+
463
+
464
+ if (files[i].size > segmentSize) {
465
+ let { streamConfig, segments } = await processFile(files[i], null, segmentSize);
466
+ files[i].src = streamConfig
467
+ for (let j = 0; j < segments.length; j++) {
468
+ segments[j].path = path
469
+ segments[j].pathname = path + '/' + segments[j].name
470
+ segments[j].directory = directory
471
+
472
+ Data.$filter.query.pathname = segments[j].pathname
473
+ Crud.send({
474
+ ...Data,
475
+ object: segments[j],
476
+ upsert: true
477
+ });
478
+ }
479
+
454
480
  }
455
481
  }
482
+
483
+ let object = input.getAttribute('object')
484
+ if (key) {
485
+ Data[Data.type] = { _id: object, [key]: files }
486
+ } else {
487
+ Data[Data.type] = files
488
+ }
489
+
490
+ // Data.$filter.query.pathname = files[i].pathname
491
+
492
+ let response = await Crud.send({
493
+ ...Data,
494
+ upsert: true
495
+ });
496
+
497
+ data.push(response)
498
+ if (response && (!object || object !== response.object)) {
499
+ Elements.setTypeValue(element, response);
500
+ }
456
501
  }
457
502
 
458
503
  let queriedElements = queryElements({ element: element[i], prefix: 'upload' })