pingdotgg / uploadthing

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

[bug]: UploadThing REST API v6/uploadFiles response url question #1007

Closed PratikPradhan987 closed 1 month ago

PratikPradhan987 commented 1 month ago

Provide environment information

System:
    OS: Windows 11 10.0.22635
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 5.22 GB / 15.85 GB
  Binaries:
    Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.2.5 - C:\Program Files\nodejs\npm.CMD
    pnpm: 7.12.2 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Chrome: 129.0.6668.90
    Edge: Chromium (127.0.2651.8)
    Internet Explorer: 11.0.22621.3566
  npmPackages:
    @uploadthing/react: ^7.0.2 => 7.0.2 
    typescript: ^5 => 5.6.2 
    uploadthing: ^7.0.2 => 7.0.2

Describe the bug

crypto.createHash('md5').update(randomString).digest('hex') + .${fileExtension}; i am using crypto to update to random name for the file

const data = { files: updatedFiles.map((file) => ({ name: file.file.name, size: file.file.size, type: file.file.type, })), acl: 'public-read', contentDisposition: 'inline', }; const options = { method: 'POST', url: 'https://api.uploadthing.com/v6/uploadFiles', headers: { // 'Content-Type': 'application/json', 'X-Uploadthing-Api-Key': process.env.NEXT_PUBLIC_UPLOADTHING_SECRET }, data: data }; const res = await axios.request(options);

   i do get the response but the url is not working 
   the url is in pending/uploading state 

Link to reproduction

https://youtu.be/TyXj5a5Uqgc?si=gx0-chYFTD-MxaBI

To reproduce

https://youtu.be/TyXj5a5Uqgc?si=gx0-chYFTD-MxaBI

not able to share the repo but create a video

Additional information

https://youtu.be/TyXj5a5Uqgc?si=gx0-chYFTD-MxaBI

not able to share the repo but create a video

๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributing

Code of Conduct

juliusmarminge commented 1 month ago

Hey, the issue you're facing is that you're not uploading the files. That endpoint just requests some presigned URLs. You then need to upload the file's content to those URLs.

If you compare to our v6 SDK, this is the step you've done: https://github.com/pingdotgg/uploadthing/blob/legacy-docs/packages/uploadthing/src/sdk/utils.ts#L135

You then need to post the files:

https://github.com/pingdotgg/uploadthing/blob/49d95d6db9e357c3af8511e83b5bc3b9652e8df7/packages/uploadthing/src/sdk/utils.ts#L184-L188


You can do it much simpler by using the v7 by generating a presigned URL yourself and uploading to our ingest servers. That's explained here: https://docs.uploadthing.com/uploading-files.