@cocreate/file 1.15.2 → 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 +19 -0
- package/README.md +10 -3
- package/demo/index.html +1 -1
- package/demo/video-segmenting.html +22 -0
- package/package.json +12 -7
- package/src/client.js +68 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
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
|
+
|
|
13
|
+
# [1.16.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.15.2...v1.16.0) (2024-02-16)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* if realtime save on file selection ([de3c32c](https://github.com/CoCreate-app/CoCreate-file/commit/de3c32cdf3a1a1c18424ef0e8554fab40a85411d))
|
|
19
|
+
|
|
1
20
|
## [1.15.2](https://github.com/CoCreate-app/CoCreate-file/compare/v1.15.1...v1.15.2) (2024-02-14)
|
|
2
21
|
|
|
3
22
|
|
package/README.md
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
# CoCreate-file
|
|
2
2
|
|
|
3
|
-
|
|
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
|

|
|
6
6
|

|
|
7
7
|

|
|
8
|
-

|
|
9
|
+

|
|
10
10
|

|
|
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
|

|
|
13
20
|
|
|
14
21
|
## [Docs & Demo](https://cocreate.app/docs/file)
|
package/demo/index.html
CHANGED
|
@@ -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.
|
|
4
|
-
"description": "A headless file uploader
|
|
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
|
@@ -180,7 +180,8 @@ async function fileEvent(event) {
|
|
|
180
180
|
if (isRealtime && isRealtime !== 'false') {
|
|
181
181
|
if (isImport || isImport == "") {
|
|
182
182
|
Import(input)
|
|
183
|
-
}
|
|
183
|
+
} else if (input.save)
|
|
184
|
+
input.save()
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
} catch (error) {
|
|
@@ -423,35 +424,80 @@ async function upload(element, data) {
|
|
|
423
424
|
|
|
424
425
|
for (let input of inputs) {
|
|
425
426
|
let Data = Elements.getObject(input);
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
427
|
+
let key = getAttribute('key')
|
|
428
|
+
if (Data.type === 'key')
|
|
429
|
+
Data.type = 'object'
|
|
429
430
|
|
|
430
|
-
|
|
431
|
+
Data.method = Data.type + '.update'
|
|
432
|
+
if (Data.array)
|
|
433
|
+
Data.array = 'files'
|
|
431
434
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
Data.type = 'object'
|
|
435
|
+
let path = input.getAttribute('path')
|
|
436
|
+
let directory = '/'
|
|
435
437
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
if (path) {
|
|
439
|
+
directory = path.split('/');
|
|
440
|
+
directory = directory[directory.length - 1];
|
|
441
|
+
if (!path.endswith('/'))
|
|
442
|
+
path += '/'
|
|
443
|
+
} else
|
|
444
|
+
path = directory = '/'
|
|
445
|
+
|
|
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: {}
|
|
441
453
|
}
|
|
442
454
|
|
|
443
|
-
Data.method = Data.type + '.update'
|
|
444
|
-
let response = await Crud.send(Data)({
|
|
445
|
-
array,
|
|
446
|
-
object,
|
|
447
|
-
upsert: true
|
|
448
|
-
});
|
|
449
455
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
+
|
|
453
480
|
}
|
|
454
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
|
+
}
|
|
455
501
|
}
|
|
456
502
|
|
|
457
503
|
let queriedElements = queryElements({ element: element[i], prefix: 'upload' })
|