mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
fixes
This commit is contained in:
parent
f98f90e58a
commit
f9480d543b
|
@ -34,7 +34,7 @@
|
||||||
download
|
download
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div style="min-height:20px" />
|
<div style="min-height:15px" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -170,6 +170,9 @@ app.get("/download/:fileId",(req,res) => {
|
||||||
let fgRQH = async (req:express.Request,res:express.Response) => {
|
let fgRQH = async (req:express.Request,res:express.Response) => {
|
||||||
files.readFileStream(req.params.fileId).then(f => {
|
files.readFileStream(req.params.fileId).then(f => {
|
||||||
res.setHeader("Content-Type",f.contentType)
|
res.setHeader("Content-Type",f.contentType)
|
||||||
|
if (f.byteSize) {
|
||||||
|
res.setHeader("Content-Length",f.byteSize)
|
||||||
|
}
|
||||||
res.status(200)
|
res.status(200)
|
||||||
f.dataStream.pipe(res)
|
f.dataStream.pipe(res)
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
|
|
@ -215,7 +215,7 @@ export default class Files {
|
||||||
|
|
||||||
// todo: move read code here
|
// 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) => {
|
return new Promise(async (resolve,reject) => {
|
||||||
if (!this.uploadChannel) {
|
if (!this.uploadChannel) {
|
||||||
reject({status:503,message:"server is not ready - please try again later"})
|
reject({status:503,message:"server is not ready - please try again later"})
|
||||||
|
@ -231,7 +231,8 @@ export default class Files {
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
contentType: file.mime,
|
contentType: file.mime,
|
||||||
dataStream: dataStream
|
dataStream: dataStream,
|
||||||
|
byteSize: file.sizeInBytes
|
||||||
})
|
})
|
||||||
|
|
||||||
for (let i = 0; i < file.messageids.length; i++) {
|
for (let i = 0; i < file.messageids.length; i++) {
|
||||||
|
|
Loading…
Reference in a new issue