webdevcody / file-drive

MIT License
214 stars 112 forks source link

Can't upload file #1

Open thuongtruong1009 opened 6 months ago

thuongtruong1009 commented 6 months ago

Hi @webdevcody

Firstly, I thank you for your file-drive web app. This is a wonderful product and I am excited about the stacks that are used in this

But when I run it locally, I create an account, then I create a new organization and upload a file, and the console displays that "can't access this org.." although the image uploaded on file store on convex

image

image

image

I hope to get support from you

Thank you very much!

ozgurcokceken commented 6 months ago

Hello, in users table your tokenIdentifier comes with undefined. To fix this you can change tokenIdentifier inside webhook which is in https.ts file.

i had the same issue and i just replaced env variable with my own domain which provided at convex/settings/auth. i dont know why but i just cant read env variables inside this file. other files works fine.

for example; ` tokenIdentifier:https://${process.env.CLERK_HOSTNAME}|${result.data.id}`,

tokenIdentifier: https://husky-profet-199.clerk.accounts.dev|${result.data.id}, ``

thuongtruong1009 commented 6 months ago

Hello, in users table your tokenIdentifier comes with undefined. To fix this you can change tokenIdentifier inside webhook which is in https.ts file.

i had the same issue and i just replaced env variable with my own domain which provided at convex/settings/auth. i dont know why but i just cant read env variables inside this file. other files works fine.

for example; ` tokenIdentifier:https://${process.env.CLERK_HOSTNAME}|${result.data.id}`,

tokenIdentifier: https://husky-profet-199.clerk.accounts.dev|${result.data.id}, ``

Oh very good. Your solution working for me. Thank you very much ❤️

ghost commented 5 months ago

And why should that cause that error and it just the same thing....I think it might not be the reason for that error.

ghost commented 5 months ago

Hello, in users table your tokenIdentifier comes with undefined. To fix this you can change tokenIdentifier inside webhook which is in https.ts file.

i had the same issue and i just replaced env variable with my own domain which provided at convex/settings/auth. i dont know why but i just cant read env variables inside this file. other files works fine.

for example; ` tokenIdentifier:https://${process.env.CLERK_HOSTNAME}|${result.data.id}`,

tokenIdentifier: https://husky-profet-199.clerk.accounts.dev|${result.data.id}, ``

Hey,it not working for me, I don't think this is the reason for the error...after doing this am still getting the same error.

ozgurcokceken commented 5 months ago

Hello, in users table your tokenIdentifier comes with undefined. To fix this you can change tokenIdentifier inside webhook which is in https.ts file. i had the same issue and i just replaced env variable with my own domain which provided at convex/settings/auth. i dont know why but i just cant read env variables inside this file. other files works fine. for example; tokenIdentifier: `https://${process.env.CLERK_HOSTNAME}|${result.data.id}`, tokenIdentifier: `https://husky-profet-199.clerk.accounts.dev|${result.data.id}`,

Hey,it not working for me, I don't think this is the reason for the error...after doing this am still getting the same error.

Are you sure you have the same problem we said earlier "undefined" at users tokenIdentifier?

ghost commented 5 months ago

Now it okay.

On Tue, Mar 12, 2024, 9:59 PM Özgür Çokçeken @.***> wrote:

Hello, in users table your tokenIdentifier comes with undefined. To fix this you can change tokenIdentifier inside webhook which is in https.ts file. i had the same issue and i just replaced env variable with my own domain which provided at convex/settings/auth. i dont know why but i just cant read env variables inside this file. other files works fine. for example; tokenIdentifier: https://${process.env.CLERK_HOSTNAME}|${ result.data.id}, tokenIdentifier: https://husky-profet-199.clerk.accounts.dev|${result.data.id},

Hey,it not working for me, I don't think this is the reason for the error...after doing this am still getting the same error.

Are you sure you have the same problem we said earlier "undefined" at users tokenIdentifier?

— Reply to this email directly, view it on GitHub https://github.com/webdevcody/file-drive/issues/1#issuecomment-1992342113, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAGKWQJD2T43QA6RUKVDVI3YX5GABAVCNFSM6AAAAABEQUJM2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJSGM2DEMJRGM . You are receiving this because you commented.Message ID: @.***>

ashux25 commented 1 month ago

Another way i found out was I create a file in app folder -> helper.js

export default function getClerkURL(){
    return process.env.CLERK_HOSTNAME
} 

In https.js now you will be able to use the secret

import getClerkURL  from "../app/helper" 
const CLERK_HOSTNAME = getClerkURL()
Rope-a-dope commented 1 month ago

It's because we need to set CLERK_HOSTNAME in Convex Environment Variables, not in env.local file. Otherwise, tokenIdentifier created will be https://underfined| $=***. But there is another problem, if we upload txt file ,will show the same toast, but the file will still be created.

Rope-a-dope commented 1 month ago

Second problems fixed. The reason why the incorrect file type is still uploaded is because we already have a post reqeust to post that file to url, the createFile is just to create an entry in files table. So before post, we must check the fileType first and toast the message, return.

    if (!orgId) return;

    const fileType = values.file[0].type;

    if (fileType in types) {
    } else {
      toast({
        variant: "destructive",
        title: "File type must be image, pdf or csv",
        description: "Your file could not be uploaded, try again later",
      });
      return;
    }

    const postUrl = await generateUploadUrl();

    const result = await fetch(postUrl, {
      method: "POST",
      headers: { "Content-Type": fileType },
      body: values.file[0],
    });
    const { storageId } = await result.json();
imedly commented 2 weeks ago

please i'm getting the same error, i don't what to do ? [CONVEX M(files:createFile)] [Request ID: b3a2182421fbddae] Server Error Uncaught ConvexError: you do not have access to this org at handler (../convex/files.ts:66:4)