@cocreate/file 1.2.13 → 1.3.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 +14 -0
- package/package.json +5 -5
- package/src/server.js +79 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.3.1](https://github.com/CoCreate-app/CoCreate-file/compare/v1.3.0...v1.3.1) (2023-06-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Update dependencies versions for [@cocreate](https://github.com/cocreate) libraries ([cb11d96](https://github.com/CoCreate-app/CoCreate-file/commit/cb11d96479aabaa10c3d655c22be442be8a4ca9a))
|
|
7
|
+
|
|
8
|
+
# [1.3.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.2.13...v1.3.0) (2023-06-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* mimeTypes ([739bacd](https://github.com/CoCreate-app/CoCreate-file/commit/739bacdc524646f0ec8a5065f6e84d87872b2a64))
|
|
14
|
+
|
|
1
15
|
## [1.2.13](https://github.com/CoCreate-app/CoCreate-file/compare/v1.2.12...v1.2.13) (2023-06-11)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/file",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
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.8.
|
|
63
|
-
"@cocreate/cli": "^1.33.
|
|
64
|
-
"@cocreate/render": "^1.24.
|
|
65
|
-
"@cocreate/utils": "^1.21.
|
|
62
|
+
"@cocreate/actions": "^1.8.29",
|
|
63
|
+
"@cocreate/cli": "^1.33.7",
|
|
64
|
+
"@cocreate/render": "^1.24.29",
|
|
65
|
+
"@cocreate/utils": "^1.21.13"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/server.js
CHANGED
|
@@ -3,7 +3,80 @@ const cli = require('@cocreate/cli')
|
|
|
3
3
|
const mime = require('mime-types')
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const path = require('path');
|
|
6
|
-
|
|
6
|
+
const mimeTypes = {
|
|
7
|
+
".aac": "audio/aac",
|
|
8
|
+
".abw": "application/x-abiword",
|
|
9
|
+
".arc": "application/x-freearc",
|
|
10
|
+
".avi": "video/x-msvideo",
|
|
11
|
+
".azw": "application/vnd.amazon.ebook",
|
|
12
|
+
".bin": "application/octet-stream",
|
|
13
|
+
".bmp": "image/bmp",
|
|
14
|
+
".bz": "application/x-bzip",
|
|
15
|
+
".bz2": "application/x-bzip2",
|
|
16
|
+
".csh": "application/x-csh",
|
|
17
|
+
".css": "text/css",
|
|
18
|
+
".csv": "text/csv",
|
|
19
|
+
".doc": "application/msword",
|
|
20
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
21
|
+
".eot": "application/vnd.ms-fontobject",
|
|
22
|
+
".epub": "application/epub+zip",
|
|
23
|
+
".gif": "image/gif",
|
|
24
|
+
".htm": "text/html",
|
|
25
|
+
".html": "text/html",
|
|
26
|
+
".ico": "image/vnd.microsoft.icon",
|
|
27
|
+
".ics": "text/calendar",
|
|
28
|
+
".jar": "application/java-archive",
|
|
29
|
+
".jpeg": "image/jpeg",
|
|
30
|
+
".jpg": "image/jpeg",
|
|
31
|
+
".js": "text/javascript",
|
|
32
|
+
".json": "application/json",
|
|
33
|
+
".jsonld": "application/ld+json",
|
|
34
|
+
".mid": "audio/midi",
|
|
35
|
+
".midi": "audio/midi",
|
|
36
|
+
".mjs": "text/javascript",
|
|
37
|
+
".mp3": "audio/mpeg",
|
|
38
|
+
".mp4": "video/mp4",
|
|
39
|
+
".mpeg": "video/mpeg",
|
|
40
|
+
".mpkg": "application/vnd.apple.installer+xml",
|
|
41
|
+
".odp": "application/vnd.oasis.opendocument.presentation",
|
|
42
|
+
".ods": "application/vnd.oasis.opendocument.spreadsheet",
|
|
43
|
+
".odt": "application/vnd.oasis.opendocument.text",
|
|
44
|
+
".oga": "audio/ogg",
|
|
45
|
+
".ogv": "video/ogg",
|
|
46
|
+
".ogx": "application/ogg",
|
|
47
|
+
".otf": "font/otf",
|
|
48
|
+
".png": "image/png",
|
|
49
|
+
".pdf": "application/pdf",
|
|
50
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
51
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
52
|
+
".rar": "application/x-rar-compressed",
|
|
53
|
+
".rtf": "application/rtf",
|
|
54
|
+
".sh": "application/x-sh",
|
|
55
|
+
".svg": "image/svg+xml",
|
|
56
|
+
".swf": "application/x-shockwave-flash",
|
|
57
|
+
".tar": "application/x-tar",
|
|
58
|
+
".tif": "image/tiff",
|
|
59
|
+
".tiff": "image/tiff",
|
|
60
|
+
".ts": "video/mp2t",
|
|
61
|
+
".ttf": "font/ttf",
|
|
62
|
+
".txt": "text/plain",
|
|
63
|
+
".vsd": "application/vnd.visio",
|
|
64
|
+
".wav": "audio/wav",
|
|
65
|
+
".weba": "audio/webm",
|
|
66
|
+
".webm": "video/webm",
|
|
67
|
+
".webp": "image/webp",
|
|
68
|
+
".woff": "font/woff",
|
|
69
|
+
".woff2": "font/woff2",
|
|
70
|
+
".xhtml": "application/xhtml+xml",
|
|
71
|
+
".xls": "application/vnd.ms-excel",
|
|
72
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
73
|
+
".xml": "application/xml",
|
|
74
|
+
".xul": "application/vnd.mozilla.xul+xml",
|
|
75
|
+
".zip": "application/zip",
|
|
76
|
+
".3gp": "video/3gpp",
|
|
77
|
+
".3g2": "video/3gpp2",
|
|
78
|
+
".7z": "application/x-7z-compressed"
|
|
79
|
+
}
|
|
7
80
|
|
|
8
81
|
module.exports = async function file(CoCreateConfig) {
|
|
9
82
|
|
|
@@ -109,7 +182,8 @@ module.exports = async function file(CoCreateConfig) {
|
|
|
109
182
|
if (parentDirectoryOnly && index) {
|
|
110
183
|
parentDirectoryOnly = parentDirectoryOnly.substring(index)
|
|
111
184
|
}
|
|
112
|
-
|
|
185
|
+
const fileExtension = path.extname(file);
|
|
186
|
+
let mimeType = mimeTypes[fileExtension]
|
|
113
187
|
let pathName = '';
|
|
114
188
|
|
|
115
189
|
if (!directoryName && directory.document && directory.document.directory)
|
|
@@ -254,7 +328,9 @@ module.exports = async function file(CoCreateConfig) {
|
|
|
254
328
|
continue
|
|
255
329
|
|
|
256
330
|
let read_type = 'utf8'
|
|
257
|
-
|
|
331
|
+
const fileExtension = path.extname(entry);
|
|
332
|
+
let mime_type = mimeTypes[fileExtension] || 'text/html'
|
|
333
|
+
|
|
258
334
|
if (/^(image|audio|video)\/[-+.\w]+/.test(mime_type)) {
|
|
259
335
|
read_type = 'base64'
|
|
260
336
|
}
|