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",