From 9f78c93adcf30ea976fa1bcceba28805e1ab7a06 Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 23 Jul 2024 12:00:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BC=93=E5=AD=98=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 1a23c3d..9232a59 100644 --- a/index.js +++ b/index.js @@ -123,7 +123,7 @@ export default class Response { } // 文件下载 - sendfile(target, filename = 'untitled') { + sendfile(target, filename = 'untitled', expires = 3600) { if (this.#ended) { return } @@ -151,7 +151,7 @@ export default class Response { } } - this.expires = 3600 + this.expires = expires if (Buffer.isBuffer(target)) { data = target @@ -184,14 +184,14 @@ export default class Response { this.body = data } - load(file, type) { + load(file, type, expires = 24 * 3600) { let stat = fs.stat(file) if (stat.isFile()) { let size = stat.size let _type = type || file.split('.').pop() || 'stream' - this.expires = 30 * 24 * 3600 + this.expires = expires this.type = _type this.length = stat.size return fs.origin.createReadStream(file).pipe(this.#res) diff --git a/package.json b/package.json index b5dbdc9..d94996f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gm5/response", - "version": "2.1.0", + "version": "2.1.1", "type": "module", "description": "对Http的response进一步封装, 提供常用的API", "main": "index.js",