pingdotgg / uploadthing

File uploads for modern web devs
https://uploadthing.com
MIT License
4.28k stars 319 forks source link

[bug]: Cant Upload Zip File #913

Closed Samz0001 closed 3 months ago

Samz0001 commented 3 months ago

I understand that this issue may be closed if it should be filed in another category

My issue

 <Label>Product File</Label>
              <UploadDropzone
                endpoint="productFileUpload"
                onClientUploadComplete={(res) => {
                  setProductFile(res[0].url);
                }}
                onUploadError={(error: Error) => {
                  throw new Error(`${error}`);
                }}
              />
              {state?.errors?.["productFile"]?.[0] && (
                <p className="text-red-500">
                  {state?.errors?.["productFile"]?.[0]}
                </p>
              )}
//core.ts
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";

const f = createUploadthing();

export const ourFileRouter = {
  imageUploader: f({ image: { maxFileSize: "4MB", maxFileCount: 5 } })
    .middleware(async ({ req }) => {
      const { getUser } = getKindeServerSession();
      const user = await getUser();

      if (!user) throw new UploadThingError("Unauthorized");

      return { userId: user.id };
    })
    .onUploadComplete(async ({ metadata, file }) => {
      console.log("Upload complete for userId:", metadata.userId);
      console.log("file url", file.url);

      return { uploadedBy: metadata.userId };
    }),

  productFileUpload: f({
    "application/zip": { maxFileSize: "4MB", maxFileCount: 1 },
  })
    .middleware(async ({ req }) => {
      const { getUser } = getKindeServerSession();
      const user = await getUser();

      if (!user) throw new UploadThingError("Unauthorized");

      return { userId: user.id };
    })
    .onUploadComplete(async ({ metadata, file }) => {
      console.log("Upload complete for userId:", metadata.userId);
      console.log("file url", file.url);

      return { uploadedBy: metadata.userId };
    }),
} satisfies FileRouter;

export type OurFileRouter = typeof ourFileRouter;
markflorkowski commented 3 months ago

What errors are you getting?

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had any activity for 10 days. It will be closed in 5 days if no further activity occurs.

github-actions[bot] commented 3 months ago

This issue has been closed because it has not had any activity for 5 days since being marked as stale.

mihirDP commented 1 month ago

What errors are you getting?

I know what project he was working and I am facing the same! There is no error at all main problem occurring here is that after user clicks the upload btn, selecting it , selects it and gets out of explorer window nothing happens! The file doesn't get uploaded. Even more it doesn't even get selected! and hence no upload happens! Here are step by step images what happens>>> image image image And below are the ss of the Product Images Uploader section: image image image image Here the images are getting uploaded successfully