pwuexecP
Convex Community14mo ago
13 replies
pwuexec

I'm trying to upload data but it says Property 'store' does not exist on type 'StorageWriter'

How can I upload stuff?
I'm reading this https://docs.convex.dev/file-storage/store-files but the .store does not exists
"convex": "^1.17.2",
export const seedTutors = internalMutation({
  handler: async (ctx) => {
    const data: TutorProfileJSON[] = JSON.parse(seedTutorsData);
    const hasData = await ctx.db.query("tutors").take(1);
    if (hasData.length > 0) {
      console.log("Data already seeded");
      return;
    }

    for (const row of data) {
      if (
        row.profileImageUrl.endsWith(".svg") ||
        row.profileImageUrl.includes("placeholder")
      ) {
        continue;
      }

      const response = await fetch(row.profileImageUrl);
      const image = await response.blob();

      const storageId = await ctx.storage.store(image);

      const userId = await ctx.db.insert("users", {
        name: row.name,
        email: `${row.name.toLowerCase().replace(" ", ".")}@mtxceltutors.com`,
        emailVerificationTime: Date.now(),
      });

      const tutorId = await ctx.db.insert("tutors", {
        user: userId,
        tags: row.tags,
        bio: {
          main: row.bio,
          session: row.sessionBio,
          short: row.bioShort,
        },
      });
    }
  },
});
Files can be uploaded to Convex from a client and stored directly, see
Storing Generated Files | Convex Developer Hub
Was this page helpful?