diff --git a/convex/files.ts b/convex/files.ts index f24620e..0787c92 100644 --- a/convex/files.ts +++ b/convex/files.ts @@ -48,8 +48,12 @@ export const saveFile = mutation({ directoryId: v.optional(v.id("directories")), storageId: v.id("_storage"), userId: v.id("users"), + mimeType: v.optional(v.string()), }, - handler: async (ctx, { name, storageId, directoryId, userId, size }) => { + handler: async ( + ctx, + { name, storageId, directoryId, userId, size, mimeType }, + ) => { const now = new Date().toISOString() await ctx.db.insert("files", { name, @@ -57,6 +61,7 @@ export const saveFile = mutation({ storageId, directoryId, userId, + mimeType, createdAt: now, updatedAt: now, }) diff --git a/convex/schema.ts b/convex/schema.ts index 14d86f5..7274c35 100644 --- a/convex/schema.ts +++ b/convex/schema.ts @@ -14,6 +14,7 @@ const schema = defineSchema({ directoryId: v.optional(v.id("directories")), name: v.string(), size: v.number(), + mimeType: v.optional(v.string()), createdAt: v.string(), updatedAt: v.string(), deletedAt: v.optional(v.string()), diff --git a/convex/users.ts b/convex/users.ts index 7974b9a..ea8baa1 100644 --- a/convex/users.ts +++ b/convex/users.ts @@ -4,7 +4,7 @@ import { query } from "./_generated/server" export const getCurrentUser = query({ handler: async (ctx) => { return await ctx.db.get( - "jd7ampv4m200xr4yk2cfncccmh7qhj34" as Id<"users">, + "j574n657f521n19v1stnr88ysd7qhbs1" as Id<"users">, ) }, }) diff --git a/src/files/files-page.tsx b/src/files/files-page.tsx index 7850b22..3054f94 100644 --- a/src/files/files-page.tsx +++ b/src/files/files-page.tsx @@ -55,6 +55,7 @@ export function FilesPage() { ) } +// tags: upload, uploadfile, uploadfilebutton, fileupload, fileuploadbutton function UploadFileButton() { const [isUploading, setIsUploading] = useState(false) const currentUser = useConvexQuery(api.users.getCurrentUser) @@ -90,6 +91,7 @@ function UploadFileButton() { storageId, name: file.name, size: file.size, + mimeType: file.type, userId: currentUser._id, })