@cocreate/file
Advanced tools
Comparing version 1.16.0 to 1.17.0
@@ -0,1 +1,13 @@ | ||
# [1.17.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.16.0...v1.17.0) (2024-03-18) | ||
### Bug Fixes | ||
* descriptions ([fe2cffc](https://github.com/CoCreate-app/CoCreate-file/commit/fe2cffc731ba9ffecbe6c5768ae43e242d9dea92)) | ||
### Features | ||
* handle mediaSegmentation, define path ([4c8e478](https://github.com/CoCreate-app/CoCreate-file/commit/4c8e478bf7ff6a382c18bfbe7af60886af9e0d9e)) | ||
# [1.16.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.15.2...v1.16.0) (2024-02-16) | ||
@@ -2,0 +14,0 @@ |
{ | ||
"name": "@cocreate/file", | ||
"version": "1.16.0", | ||
"description": "A headless file uploader that uses HTML5 attributes for customization. Allows easy upload of files to server.", | ||
"version": "1.17.0", | ||
"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.", | ||
"keywords": [ | ||
"file", | ||
"file uploader", | ||
"headless", | ||
"HTML5 attributes", | ||
"server upload", | ||
"customizable uploader", | ||
"file upload API", | ||
"no UI upload", | ||
"background file upload", | ||
"programmatic file upload", | ||
"headless file management", | ||
"cocreate", | ||
"low-code-framework", | ||
"no-code-framework", | ||
"cocreatejs", | ||
"cocreatejs-component", | ||
"cocreate-framework", | ||
"no-code", | ||
"low-code", | ||
"collaborative-framework", | ||
"realtime", | ||
"realtime-framework", | ||
"collaboration", | ||
"shared-editing", | ||
@@ -20,0 +25,0 @@ "html5-framework", |
# CoCreate-file | ||
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) | ||
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) | ||
@@ -8,6 +8,13 @@ ![minified](https://img.badgesize.io/https://cdn.cocreate.app/file/latest/CoCreate-file.min.js?style=flat-square&label=minified&color=orange) | ||
![brotli](https://img.badgesize.io/https://cdn.cocreate.app/file/latest/CoCreate-file.min.js?compression=brotli&style=flat-square&label=brotli) | ||
![GitHub latest release](https://img.shields.io/github/v/release/CoCreate-app/CoCreate-action?style=flat-square) | ||
![License](https://img.shields.io/github/license/CoCreate-app/CoCreate-action?style=flat-square) | ||
![GitHub latest release](https://img.shields.io/github/v/release/CoCreate-app/CoCreate-file?style=flat-square) | ||
![License](https://img.shields.io/github/license/CoCreate-app/CoCreate-file?style=flat-square) | ||
![Hiring](https://img.shields.io/static/v1?style=flat-square&label=&message=Hiring&color=blueviolet) | ||
## Key Features | ||
- **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. | ||
- **Local & Server File Operations**: Supports reading, writing, and uploading files both locally and to the server, catering to a wide range of application needs. | ||
- **Graceful Fallbacks**: Implements graceful fallbacks to the standard HTML5 file input API, ensuring compatibility and functionality across different browsers and environments. | ||
- **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. | ||
![CoCreate-file](https://cdn.cocreate.app/docs/CoCreate-file.gif) | ||
@@ -14,0 +21,0 @@ |
@@ -427,31 +427,76 @@ /******************************************************************************** | ||
let Data = Elements.getObject(input); | ||
if (Data.type) { | ||
if (input.getFilter) | ||
Data.$filter = await input.getFilter() | ||
let key = getAttribute('key') | ||
if (Data.type === 'key') | ||
Data.type = 'object' | ||
let files = await getFiles(input) | ||
Data.method = Data.type + '.update' | ||
if (Data.array) | ||
Data.array = 'files' | ||
let key = getAttribute('key') | ||
if (Data.type === 'key') | ||
Data.type = 'object' | ||
let path = input.getAttribute('path') | ||
let directory = '/' | ||
let object = input.getAttribute('object') | ||
if (key) { | ||
Data[Data.type] = { _id: object, [key]: files } | ||
} else { | ||
Data[Data.type] = files | ||
if (path) { | ||
directory = path.split('/'); | ||
directory = directory[directory.length - 1]; | ||
if (!path.endswith('/')) | ||
path += '/' | ||
} else | ||
path = directory = '/' | ||
if (input.getFilter) { | ||
Data.$filter = await input.getFilter() | ||
if (!Data.$filter.query) | ||
Data.$filter.query = {} | ||
} else | ||
Data.$filter = { | ||
query: {} | ||
} | ||
Data.method = Data.type + '.update' | ||
let response = await Crud.send(Data)({ | ||
array, | ||
object, | ||
upsert: true | ||
}); | ||
data.push(response) | ||
if (response && (!object || object !== response.object)) { | ||
Elements.setTypeValue(element, response); | ||
let files = await getFiles(input) | ||
let segmentSize = 10 * 1024 * 1024 | ||
for (let i = 0; i < files.length; i++) { | ||
files[i].path = path | ||
files[i].pathname = path + '/' + files[i].name | ||
files[i].directory = directory | ||
if (files[i].size > segmentSize) { | ||
let { streamConfig, segments } = await processFile(files[i], null, segmentSize); | ||
files[i].src = streamConfig | ||
for (let j = 0; j < segments.length; j++) { | ||
segments[j].path = path | ||
segments[j].pathname = path + '/' + segments[j].name | ||
segments[j].directory = directory | ||
Data.$filter.query.pathname = segments[j].pathname | ||
Crud.send({ | ||
...Data, | ||
object: segments[j], | ||
upsert: true | ||
}); | ||
} | ||
} | ||
} | ||
let object = input.getAttribute('object') | ||
if (key) { | ||
Data[Data.type] = { _id: object, [key]: files } | ||
} else { | ||
Data[Data.type] = files | ||
} | ||
// Data.$filter.query.pathname = files[i].pathname | ||
let response = await Crud.send({ | ||
...Data, | ||
upsert: true | ||
}); | ||
data.push(response) | ||
if (response && (!object || object !== response.object)) { | ||
Elements.setTypeValue(element, response); | ||
} | ||
} | ||
@@ -458,0 +503,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143189
17
1251
99