diff --git a/src/tdtmap/tdtmap.controller.ts b/src/tdtmap/tdtmap.controller.ts index 27276cc..13fb33e 100644 --- a/src/tdtmap/tdtmap.controller.ts +++ b/src/tdtmap/tdtmap.controller.ts @@ -70,6 +70,7 @@ export class TdtmapController { // minio 中存在,从 minio 取出 const dbItem:Buffer = await this.tdtmapService.getTileFromLocal(tileFormattedName) // 从 minio 取出来 cacheMap.set(tileFormattedName, dbItem) + Buffer.from(dbItem as any, 'utf-8') return new StreamableFile(dbItem); } else { // 如果本地数据库都不存在 @@ -85,7 +86,6 @@ export class TdtmapController { cacheMap.set(tileFormattedName, res.data) const saveSuccess = await this.tdtmapService.setTileToLocal(tileFormattedName, res.data); if (saveSuccess) bloomFilter.add(tileFormattedName); - Buffer.from(res.data, 'utf-8') return new StreamableFile(res.data); // 请求成功 } else { diff --git a/src/tdtmap/tdtmap.service.ts b/src/tdtmap/tdtmap.service.ts index 697beb5..19f8166 100644 --- a/src/tdtmap/tdtmap.service.ts +++ b/src/tdtmap/tdtmap.service.ts @@ -30,10 +30,12 @@ export class TdtmapService { async getTileFromLocal(tile_name:string):Promise { return new Promise(async (resolve, reject) => { const stream = await this.minioClient.getObject("nestfiles", tile_name) - let res:any = null - stream.on("data", (data) => { res = data }) + const res:any[] = [] + stream.on("data", (data:Buffer) => { + if (Buffer.isBuffer(data)) res.push(data) + }) stream.on("end", () => { - if (res) resolve(res) + if (res.length > 0) resolve(Buffer.concat(res)) else reject() }) stream.on("error", () => { reject() })