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!
|
fileApiRoutes.use("*", getAccount)
|
||||||
/*
|
|
||||||
|
|
||||||
/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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default function (files: Files) {
|
export default function (files: Files) {
|
||||||
fileApiRoutes.get(
|
fileApiRoutes.get(
|
||||||
|
@ -37,7 +27,7 @@ export default function (files: Files) {
|
||||||
if (!acc) return
|
if (!acc) return
|
||||||
let accId = acc.id
|
let accId = acc.id
|
||||||
|
|
||||||
ctx.json(
|
return ctx.json(
|
||||||
acc.files
|
acc.files
|
||||||
.map((e) => {
|
.map((e) => {
|
||||||
let fp = files.files[e]
|
let fp = files.files[e]
|
||||||
|
|
|
@ -32,7 +32,7 @@ export default function (files: Files) {
|
||||||
let file = files.files[fileId]
|
let file = files.files[fileId]
|
||||||
ctx.header("Access-Control-Allow-Origin", "*")
|
ctx.header("Access-Control-Allow-Origin", "*")
|
||||||
ctx.header("Content-Security-Policy", "sandbox allow-scripts")
|
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) {
|
||||||
if (file.visibility == "private") {
|
if (file.visibility == "private") {
|
||||||
|
@ -68,6 +68,8 @@ export default function (files: Files) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(range)
|
||||||
|
|
||||||
return files
|
return files
|
||||||
.readFileStream(fileId, range)
|
.readFileStream(fileId, range)
|
||||||
.then(async (stream) => {
|
.then(async (stream) => {
|
||||||
|
@ -84,7 +86,7 @@ export default function (files: Files) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.req.method == "HEAD" ? ctx.body(null) : ctx.stream(async (webStream) => {
|
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) => {
|
.catch((err) => {
|
||||||
|
|
Loading…
Reference in a new issue