File sharing

This commit is contained in:
2026-10-29 20:44:26 -03:00
parent b65d8efad8
commit de1ad70068
18 changed files with 582 additions and 59 deletions
+15
View File
@@ -0,0 +1,15 @@
import { define } from "@/utils.ts";
import type { SharedFileEntry } from "@/src/files.ts";
import { get_shared_file, share_not_found } from "@/src/shares.ts";
export const handler = define.handlers({
async GET(ctx) {
const shared = await get_shared_file(ctx.params.id);
if (!shared) {
return share_not_found();
}
return Response.json({ size: shared.file.size, metadata: shared.share.metadata } satisfies SharedFileEntry, {
headers: { "Cache-Control": "no-store" },
});
},
});
+14
View File
@@ -0,0 +1,14 @@
import { define } from "@/utils.ts";
import { get_shared_file, share_not_found } from "@/src/shares.ts";
import { upload_response } from "@/src/storage.ts";
export const handler = define.handlers({
// Streams the encrypted file, the recipient decrypts it with the secret in the link
async GET(ctx) {
const shared = await get_shared_file(ctx.params.id);
if (!shared) {
return share_not_found();
}
return await upload_response(shared.file.storage_id) ?? share_not_found();
},
});