This commit is contained in:
May 2023-02-27 15:20:40 -08:00
parent f98f90e58a
commit f9480d543b
3 changed files with 7 additions and 3 deletions

View file

@ -34,7 +34,7 @@
download
</button>
<div style="min-height:20px" />
<div style="min-height:15px" />
</div>
</div>
</body>

View file

@ -170,6 +170,9 @@ app.get("/download/:fileId",(req,res) => {
let fgRQH = async (req:express.Request,res:express.Response) => {
files.readFileStream(req.params.fileId).then(f => {
res.setHeader("Content-Type",f.contentType)
if (f.byteSize) {
res.setHeader("Content-Length",f.byteSize)
}
res.status(200)
f.dataStream.pipe(res)
}).catch((err) => {

View file

@ -215,7 +215,7 @@ export default class Files {
// todo: move read code here
readFileStream(uploadId: string):Promise<{dataStream:Readable,contentType:string}> {
readFileStream(uploadId: string):Promise<{dataStream:Readable,contentType:string,byteSize?:number}> {
return new Promise(async (resolve,reject) => {
if (!this.uploadChannel) {
reject({status:503,message:"server is not ready - please try again later"})
@ -231,7 +231,8 @@ export default class Files {
resolve({
contentType: file.mime,
dataStream: dataStream
dataStream: dataStream,
byteSize: file.sizeInBytes
})
for (let i = 0; i < file.messageids.length; i++) {