feat: add mime type field to files

This commit is contained in:
2025-09-14 18:49:28 +00:00
parent 67383c1c4e
commit bcde0532fc
4 changed files with 10 additions and 2 deletions

View File

@@ -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,
})

View File

@@ -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()),

View File

@@ -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">,
)
},
})

View File

@@ -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,
})