Elliott-Chong / chatpdf-yt

https://chatpdf-elliott.vercel.app
641 stars 263 forks source link

[Error: ENOENT: no such file or directory, open 'C:\tmp\elliott1695549520613.pdf'] { #14

Open Saunakghosh10 opened 9 months ago

Saunakghosh10 commented 9 months ago

Screenshot (7) facing issue with this.. [Error: ENOENT: no such file or directory, open 'C:\tmp\elliott1695549520613.pdf'] { errno: -4058, code: 'ENOENT', syscall: 'open', path: 'C:\tmp\elliott1695549520613.pdf' }

MulaMediaMarketing commented 9 months ago

I'm having the same problem, after i upload the pdf i get this message, and no redirect to view the pdf file

brooksa-chemtest commented 9 months ago

Same issue here. PDF appears in AWS but then nothing else happens.

brooksa-chemtest commented 9 months ago

Actually try changing the folder in the file_name to /temp/... instead of /tmp/.

Seemed to fix it on my Windows PC.

Gxgxn commented 9 months ago

The following works for Windows. Otherwise, run your file in WSL, since the deployment will be on linux

// import node:os 
 let file_name;
    if (os.platform() === "win32") {
      file_name = `C:\\Users\\${
        os.userInfo().username
      }\\AppData\\Local\\Temp\\pdf-${Date.now()}.pdf`;
    } else {
      file_name = `/tmp/pdf-${Date.now()}.pdf`;
    }
Nipunwalia08 commented 9 months ago

none of these solved this issue, did it solved for anyone else

farrukh007 commented 8 months ago

The following works for Windows. Otherwise, run your file in WSL, since the deployment will be on linux

// import node:os 
 let file_name;
    if (os.platform() === "win32") {
      file_name = `C:\\Users\\${
        os.userInfo().username
      }\\AppData\\Local\\Temp\\pdf-${Date.now()}.pdf`;
    } else {
      file_name = `/tmp/pdf-${Date.now()}.pdf`;
    }

thanks... its working

farrukh007 commented 8 months ago

none of these solved this issue, did it solved for anyone else

your should try this.. its working...

// import os from "os"; let file_name; if (os.platform() === "win32") { file_name = C:\\Users\\${ os.userInfo().username }\\AppData\\Local\\Temp\\pdf-${Date.now().toString()}.pdf; } else { file_name = /tmp/pdf-${Date.now()}.pdf; }

AndrewThien commented 7 months ago

This pull request will solve the problem for anyone who needs it, especially for deployment on Vercel. https://github.com/Elliott-Chong/chatpdf-yt/pull/36 Hope it helps

Sudipta013 commented 3 months ago

Hey guys i have found a simple solution for this.. While i was debugging this Axios error: internal server error 500 : IF you notice your concole in code editor there might be written file/module not found error. Solution: When you are trying to upload a File....

Check if the file is successfully uploaded to S3. If yes, then your connection with S3 is all good and UploadtoS3() function has no issues. Now, check if you follow the code of route.ts. It calls the function loads3intoPinecone() which takes us to pinecone.ts. Now in pinecone.ts under the method loads3intoPinecone(), the method downloadfrons3 is called which helps us to download our document from S3. This takes us s3-server.ts file , here we are using fs module to write our downloaded file into a tmp file. fs.writeFileSync(file_name, obj.Body as Buffer) i suggest try cosole.log(file_name) tocheck if you are getting the file_name if not which was in my case you can follow the next step. Now , As the file_name is not available since the module/file is not downloaded from s3 a server-side error is poping up and also module not found error. Finally, To fix this issue, you can try creating the /tmp directory manually and setting the correct permissions to make it writable. For this- Go to the folder of your Project NOTE: This is for windows open the path in terminal and type the following command mkdir /tmp icacls C:\tmp /grant Everyone:F

rohitkf commented 2 months ago

Solve this by creating a file and folder :

import path from 'path'
// Create directory
      const tmpDir = '/tmp' // Update this to the appropriate directory if needed

      // Check if the directory exists, if not, create it
      if (!fs.existsSync(tmpDir)) {
        fs.mkdirSync(tmpDir)
      }

      // const file_name = `/tmp/elliott${Date.now().toString()}.pdf`;
      const file_name = path.join(
        tmpDir,
        `chatpdf-${Date.now().toString()}.pdf`
      )