@cocreate/file 1.9.10 → 1.11.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 +27 -0
- package/CoCreate.config.js +1 -2
- package/docs/index.html +2 -2
- package/package.json +5 -5
- package/src/server.js +18 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
# [1.11.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.10.0...v1.11.0) (2023-11-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump dependencies for latest features ([c268d0f](https://github.com/CoCreate-app/CoCreate-file/commit/c268d0fa6ddf28a8149d7ab59f28cbd491eea9a1))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* symlinks will find realpath to upload ([0984755](https://github.com/CoCreate-app/CoCreate-file/commit/0984755e91cfcf5e819130502d5541f97d8bb9b1))
|
|
12
|
+
|
|
13
|
+
# [1.10.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.9.10...v1.10.0) (2023-11-09)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* .ico content-type ([8f91239](https://github.com/CoCreate-app/CoCreate-file/commit/8f91239f3658d24363631edfe52d384709e432b4))
|
|
19
|
+
* if symbolic link skip ([fb0f4d7](https://github.com/CoCreate-app/CoCreate-file/commit/fb0f4d7d60a1d24d1776199c7a45d701426d3f60))
|
|
20
|
+
* meta name typo ([22e2888](https://github.com/CoCreate-app/CoCreate-file/commit/22e2888befd95f84ec214014de94872913092e6e))
|
|
21
|
+
* update host ([f5ec5e0](https://github.com/CoCreate-app/CoCreate-file/commit/f5ec5e0c84b84942749c400bfc4e366ef44a1ea9))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* support webmanifest file type ([aca211d](https://github.com/CoCreate-app/CoCreate-file/commit/aca211d6c4fa830a1934ae68c98527f25f75baf6))
|
|
27
|
+
|
|
1
28
|
## [1.9.10](https://github.com/CoCreate-app/CoCreate-file/compare/v1.9.9...v1.9.10) (2023-11-03)
|
|
2
29
|
|
|
3
30
|
|
package/CoCreate.config.js
CHANGED
package/docs/index.html
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
sizes="32x32"
|
|
12
12
|
href="https://cocreate.app/images/favicon.ico" />
|
|
13
13
|
<meta
|
|
14
|
-
|
|
14
|
+
name="description"
|
|
15
15
|
content="A convenient chain handler allows user to chain multiple components together. When one file is complete next one will start untill all file completed." />
|
|
16
16
|
<meta
|
|
17
|
-
|
|
17
|
+
name="keywords"
|
|
18
18
|
content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
19
19
|
<meta name="robots" content="index,follow" />
|
|
20
20
|
<meta
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/file",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "A headless file uploader that uses HTML5 attributes for customization. Allows easy upload of files to server.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"webpack-log": "^3.0.1"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@cocreate/actions": "^1.12.
|
|
63
|
-
"@cocreate/config": "^1.6.
|
|
64
|
-
"@cocreate/render": "^1.
|
|
65
|
-
"@cocreate/utils": "^1.
|
|
62
|
+
"@cocreate/actions": "^1.12.3",
|
|
63
|
+
"@cocreate/config": "^1.6.8",
|
|
64
|
+
"@cocreate/render": "^1.30.1",
|
|
65
|
+
"@cocreate/utils": "^1.27.1"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/server.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const crud = require('@cocreate/crud-client')
|
|
2
2
|
const Config = require('@cocreate/config')
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const realpathAsync = fs.promises.realpath;
|
|
5
|
+
|
|
4
6
|
const path = require('path');
|
|
5
7
|
const mimeTypes = {
|
|
6
8
|
".aac": "audio/aac",
|
|
@@ -22,7 +24,7 @@ const mimeTypes = {
|
|
|
22
24
|
".gif": "image/gif",
|
|
23
25
|
".htm": "text/html",
|
|
24
26
|
".html": "text/html",
|
|
25
|
-
".ico": "image/
|
|
27
|
+
".ico": "image/x-icon",
|
|
26
28
|
".ics": "text/calendar",
|
|
27
29
|
".jar": "application/java-archive",
|
|
28
30
|
".jpeg": "image/jpeg",
|
|
@@ -63,6 +65,7 @@ const mimeTypes = {
|
|
|
63
65
|
".wav": "audio/wav",
|
|
64
66
|
".weba": "audio/webm",
|
|
65
67
|
".webm": "video/webm",
|
|
68
|
+
".webmanifest": "application/manifest+json",
|
|
66
69
|
".webp": "image/webp",
|
|
67
70
|
".woff": "font/woff",
|
|
68
71
|
".woff2": "font/woff2",
|
|
@@ -176,7 +179,14 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
176
179
|
}
|
|
177
180
|
if (skip) continue
|
|
178
181
|
|
|
179
|
-
let isDirectory
|
|
182
|
+
let isDirectory
|
|
183
|
+
let isSymlink = fs.lstatSync(`${entryPath}/${file}`).isSymbolicLink()
|
|
184
|
+
if (isSymlink) {
|
|
185
|
+
let symlinkPath = await realpathAsync(`${entryPath}/${file}`)
|
|
186
|
+
isDirectory = fs.existsSync(symlinkPath) && fs.lstatSync(symlinkPath).isDirectory()
|
|
187
|
+
} else
|
|
188
|
+
isDirectory = fs.existsSync(`${entryPath}/${file}`) && fs.lstatSync(`${entryPath}/${file}`).isDirectory()
|
|
189
|
+
|
|
180
190
|
let name = file
|
|
181
191
|
let source = ''
|
|
182
192
|
|
|
@@ -226,7 +236,7 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
226
236
|
if (isDirectory)
|
|
227
237
|
mimeType = "text/directory"
|
|
228
238
|
else
|
|
229
|
-
source = getSource(`${entryPath}/${file}`, mimeType)
|
|
239
|
+
source = await getSource(`${entryPath}/${file}`, mimeType, isSymlink)
|
|
230
240
|
|
|
231
241
|
let values = {
|
|
232
242
|
'{{name}}': name || '',
|
|
@@ -300,13 +310,17 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
|
|
|
300
310
|
}
|
|
301
311
|
|
|
302
312
|
|
|
303
|
-
function getSource(path, mimeType) {
|
|
313
|
+
async function getSource(path, mimeType, isSymlink) {
|
|
304
314
|
let readType = 'utf8'
|
|
305
315
|
if (mimeType === 'image/svg+xml') {
|
|
306
316
|
readType = 'utf8';
|
|
307
317
|
} else if (/^(image|audio|video)\/[-+.\w]+/.test(mimeType)) {
|
|
308
318
|
readType = 'base64';
|
|
309
319
|
}
|
|
320
|
+
|
|
321
|
+
if (isSymlink)
|
|
322
|
+
path = await realpathAsync(path)
|
|
323
|
+
|
|
310
324
|
let binary = fs.readFileSync(path);
|
|
311
325
|
let content = new Buffer.from(binary).toString(readType);
|
|
312
326
|
|