fixed oauth and uploading and file details

This commit is contained in:
2025-04-14 11:59:54 +02:00
parent 799c7d7cec
commit fbf1c95b1b
4 changed files with 8 additions and 6 deletions
+3 -2
View File
@@ -6,6 +6,7 @@
import { useEffect, useState } from "react";
import toast from "react-hot-toast";
import { useRouter } from "next/navigation";
import { env } from "~/env.js";
interface File {
id: string;
@@ -97,7 +98,7 @@ export default function FileGrid({ session }: FileGridProps) {
const handleCopyUrl = (url: string) => {
navigator.clipboard
.writeText(url)
.writeText(env.PAGE_URL + url)
.then(() => toast.success("File URL copied to clipboard!"))
.catch(() => toast.error("Failed to copy URL."));
};
@@ -136,7 +137,7 @@ export default function FileGrid({ session }: FileGridProps) {
className="flex max-w-xs flex-col gap-4 rounded-xl bg-white/10 p-4 hover:bg-white/20"
>
<button onClick={() => router.push(file.url)}>
<button onClick={() => router.push(env.PAGE_URL + file.url)}>
<h3 className="text-2xl font-bold">{file.name}</h3>
</button>
<div className="flex gap-2">
+1 -4
View File
@@ -61,14 +61,11 @@ export async function POST(req: Request) {
try {
const filePath = path.join(uploadDir, fileName);
await fs.writeFile(filePath, fileBuffer);
const pageurl = new URL(req.url);
//get root path of the url
const pagePath = `${pageurl.protocol}//${pageurl.host}`;
// Save file metadata to the database
const newFile = await db.file.create({
data: {
url: `${pagePath}/share?id=${fileName}`,
url: `/share?id=${fileName}`,
name: fileName,
size: fileBuffer.length,
extension: path.extname(fileName),