feat: add mime type field to files
This commit is contained in:
@@ -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,
|
||||
})
|
||||
|
@@ -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()),
|
||||
|
@@ -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">,
|
||||
)
|
||||
},
|
||||
})
|
||||
|
@@ -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,
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user