@cocreate/file 1.15.0 → 1.15.1
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 +7 -0
- package/package.json +1 -1
- package/src/client.js +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.15.1](https://github.com/CoCreate-app/CoCreate-file/compare/v1.15.0...v1.15.1) (2024-02-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add file.size and add missing object param ([32f8508](https://github.com/CoCreate-app/CoCreate-file/commit/32f85080079dcb91fee2bb294b72d16d769b3440))
|
|
7
|
+
|
|
1
8
|
# [1.15.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.14.2...v1.15.0) (2024-02-05)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -151,6 +151,9 @@ async function fileEvent(event) {
|
|
|
151
151
|
if (!files[i].src)
|
|
152
152
|
await readFile(files[i])
|
|
153
153
|
|
|
154
|
+
if (!files[i].size)
|
|
155
|
+
files[i].size = handle.size
|
|
156
|
+
|
|
154
157
|
files[i].directory = handle.directory || '/'
|
|
155
158
|
files[i].path = handle.path || '/'
|
|
156
159
|
files[i].pathname = handle.pathname || '/' + handle.name
|
|
@@ -232,9 +235,11 @@ async function getFiles(fileInputs) {
|
|
|
232
235
|
for (let file of Array.from(selected.values())) {
|
|
233
236
|
if (!file.src)
|
|
234
237
|
await readFile(file)
|
|
238
|
+
let fileObject = { ...file }
|
|
239
|
+
fileObject.size = file.size
|
|
240
|
+
await getCustomData(fileObject)
|
|
235
241
|
|
|
236
|
-
|
|
237
|
-
files.push(file)
|
|
242
|
+
files.push(fileObject)
|
|
238
243
|
}
|
|
239
244
|
}
|
|
240
245
|
}
|
|
@@ -267,14 +272,11 @@ function readFile(file) {
|
|
|
267
272
|
|
|
268
273
|
if (fileType[1] === 'directory') {
|
|
269
274
|
return resolve(file)
|
|
270
|
-
} else if ([
|
|
271
|
-
|| fileType[0] === 'image') {
|
|
275
|
+
} else if (fileType[0] === 'image') {
|
|
272
276
|
readAs = 'readAsDataURL';
|
|
273
|
-
} else if ([
|
|
274
|
-
|| fileType[0] === 'video') {
|
|
277
|
+
} else if (fileType[0] === 'video') {
|
|
275
278
|
readAs = 'readAsDataURL';
|
|
276
|
-
} else if ([
|
|
277
|
-
|| fileType[0] === 'audio') { // updated condition
|
|
279
|
+
} else if (fileType[0] === 'audio') {
|
|
278
280
|
readAs = 'readAsDataURL';
|
|
279
281
|
} else if (fileType[1] === 'pdf') {
|
|
280
282
|
readAs = 'readAsDataURL';
|
|
@@ -429,13 +431,11 @@ async function upload(element, data) {
|
|
|
429
431
|
if (Data.type === 'key')
|
|
430
432
|
Data.type = 'object'
|
|
431
433
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
Data[Data.type] = files
|
|
438
|
-
}
|
|
434
|
+
let object = input.getAttribute('object')
|
|
435
|
+
if (key) {
|
|
436
|
+
Data[Data.type] = { _id: object, [key]: files }
|
|
437
|
+
} else {
|
|
438
|
+
Data[Data.type] = files
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
Data.method = Data.type + '.update'
|