mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
Cool i have stuf to fix :3
This commit is contained in:
parent
9ff8f645eb
commit
dcf35f80b3
|
@ -14,17 +14,7 @@ export let fileApiRoutes = new Hono<{
|
|||
}
|
||||
}>()
|
||||
|
||||
fileApiRoutes.use("*", getAccount) // :warning: /list somehow crashes Hono with an internal error!
|
||||
/*
|
||||
|
||||
/home/jack/Code/Web/monofile/node_modules/.pnpm/@hono+node-server@1.2.0/node_modules/@hono/node-server/dist/listener.js:55
|
||||
const contentType = res.headers.get("content-type") || "";
|
||||
^
|
||||
|
||||
TypeError: Cannot read properties of undefined (reading 'get')
|
||||
at Server.<anonymous> (/home/jack/Code/Web/monofile/node_modules/.pnpm/@hono+node-server@1.2.0/node_modules/@hono/node-server/dist/listener.js:55:37)
|
||||
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
|
||||
*/
|
||||
fileApiRoutes.use("*", getAccount)
|
||||
|
||||
export default function (files: Files) {
|
||||
fileApiRoutes.get(
|
||||
|
@ -37,7 +27,7 @@ export default function (files: Files) {
|
|||
if (!acc) return
|
||||
let accId = acc.id
|
||||
|
||||
ctx.json(
|
||||
return ctx.json(
|
||||
acc.files
|
||||
.map((e) => {
|
||||
let fp = files.files[e]
|
||||
|
|
|
@ -32,7 +32,7 @@ export default function (files: Files) {
|
|||
let file = files.files[fileId]
|
||||
ctx.header("Access-Control-Allow-Origin", "*")
|
||||
ctx.header("Content-Security-Policy", "sandbox allow-scripts")
|
||||
ctx.header("Content-Disposition", `${ctx.req.query("attachment") == "1" ? "attachment" : "inline"}; filename="${file.filename.replaceAll("\n","\\n")}"`)
|
||||
ctx.header("Content-Disposition", `${ctx.req.query("attachment") == "1" ? "attachment" : "inline"}; filename="${encodeURI(file.filename.replaceAll("\n","\\n"))}"`)
|
||||
|
||||
if (file) {
|
||||
if (file.visibility == "private") {
|
||||
|
@ -68,6 +68,8 @@ export default function (files: Files) {
|
|||
}
|
||||
}
|
||||
|
||||
console.log(range)
|
||||
|
||||
return files
|
||||
.readFileStream(fileId, range)
|
||||
.then(async (stream) => {
|
||||
|
@ -84,7 +86,7 @@ export default function (files: Files) {
|
|||
}
|
||||
|
||||
return ctx.req.method == "HEAD" ? ctx.body(null) : ctx.stream(async (webStream) => {
|
||||
webStream.pipe(Readable.toWeb(stream) as ReadableStream).catch(e => {}) // emits an AbortError for some reason so this catches that
|
||||
webStream.pipe(Readable.toWeb(stream.on("error", e => {})) as ReadableStream).catch(e => {})
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
Loading…
Reference in a new issue