Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't upload file #1

Open
thuongtruong1009 opened this issue Mar 11, 2024 · 10 comments
Open

Can't upload file #1

thuongtruong1009 opened this issue Mar 11, 2024 · 10 comments

Comments

@thuongtruong1009
Copy link

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
Copy link

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
Copy link
Author

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
Copy link

ghost commented Mar 12, 2024

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
Copy link

ghost commented Mar 12, 2024

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
Copy link

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
Copy link

ghost commented Mar 12, 2024 via email

@ashux25
Copy link

ashux25 commented Jul 12, 2024

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
Copy link

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
Copy link

Rope-a-dope commented Jul 13, 2024

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
Copy link

imedly commented Aug 22, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants