file-handle 0.0.1 → 0.0.3
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/README.md +5 -1
- package/package.json +14 -2
- package/server/routes/api.js +2 -2
package/README.md
CHANGED
|
@@ -32,7 +32,11 @@ npm install -g file-handle
|
|
|
32
32
|
Run the following command in the directory you wish to share to start the file server:
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
file-handle
|
|
35
|
+
> file-handle
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
> fh
|
|
36
40
|
```
|
|
37
41
|
|
|
38
42
|
This will start the server on the default port (6688) and use the current working directory as the root directory.
|
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "file-handle",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"author": "jsonhandle@gmail.com",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "A simple local web file server with a user-friendly interface, allowing easy file upload, download, preview, and management through a browser. \n一个简易的文件服务器,方便通过浏览器来浏览、上传或管理目录和文件. ",
|
|
6
6
|
"main": "server/index.js",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"file-handle",
|
|
10
|
+
"file",
|
|
11
|
+
"server",
|
|
12
|
+
"upload",
|
|
13
|
+
"download",
|
|
14
|
+
"preview",
|
|
15
|
+
"file",
|
|
16
|
+
"serve",
|
|
17
|
+
"web-server",
|
|
18
|
+
"http-server"
|
|
19
|
+
],
|
|
8
20
|
"bin": {
|
|
9
21
|
"file-handle": "server/bin/cli.js",
|
|
10
22
|
"fh": "server/bin/cli.js"
|
package/server/routes/api.js
CHANGED
|
@@ -69,7 +69,7 @@ export function createApiRouter(config) {
|
|
|
69
69
|
router.get('/get', async (req, res, next) => {
|
|
70
70
|
try {
|
|
71
71
|
const { path: targetPath = '/' } = req.query;
|
|
72
|
-
const fullPath = normalizePath(targetPath, config.rootDir);
|
|
72
|
+
const fullPath = normalizePath(decodeURIComponent(targetPath), config.rootDir);
|
|
73
73
|
const stats = await fs.stat(fullPath);
|
|
74
74
|
const self = await fs.lstat(fullPath);
|
|
75
75
|
const isDirectory = stats.isDirectory();
|
|
@@ -151,7 +151,7 @@ export function createApiRouter(config) {
|
|
|
151
151
|
throw new FileOperationError('Cannot download a directory', 400);
|
|
152
152
|
}
|
|
153
153
|
const filename = path.basename(fullPath);
|
|
154
|
-
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`);
|
|
154
|
+
res.setHeader('Content-Disposition', `attachment; filename="${encodeURIComponent(filename)}"`);
|
|
155
155
|
res.setHeader('Content-Type', 'application/octet-stream');
|
|
156
156
|
res.setHeader('Content-Length', stats.size);
|
|
157
157
|
const fileStream = await fs.readFile(fullPath);
|