pingdotgg / uploadthing

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

Can't find a way to access uploaded file url #23

Closed thebishalniroula closed 1 year ago

thebishalniroula commented 1 year ago

The uploaded file url logs on the console but I cant find a way to access it.

kj-1809 commented 1 year ago

To access the uploaded file url in the code : You upload the file using the startUpload() function. You can easily await that and get the url as it returns a promise. const data = await startUpload()

data is an array of all the files uploaded.

So you can map through the array and access the fileUrl property.

data.forEach((file) => { console.log(file.fileUrl) // do whatever you want with the url })

Hope this helped !

thebishalniroula commented 1 year ago

@kj-1809 Can you tell me where can I import from the startUpload or useUploadThing hook in the latest version of uploadthing?

kj-1809 commented 1 year ago

Well , it was supported in uploadThing 1.x i guess now the version has already reached 3.x and an upload button has been added so checkout the docs for the latest syntax and features . Don't use startUpload()