Closed thebishalniroula closed 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 !
@kj-1809 Can you tell me where can I import from the startUpload or useUploadThing hook in the latest version of uploadthing?
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()
The uploaded file url logs on the console but I cant find a way to access it.