Reading a s3 file on the server
Unanswered
Dutch Smoushond posted this in #help-forum
Dutch SmoushondOP
To bypass the 4.5mb limit vercel has on the size of files, Im using s3 to upload it and then have the file read on the server and this is my code on the frontend
How can I have the file that is just uploaded by the user sent to the backend? I have another function to upload a file that is smaller, can I just pass a url or something similar?
const largeFileUpload = async () => {
setIsLoading(true) // Set loading state to true
const signedURLResult = await getSignedURL()
if (signedURLResult.failure !== undefined) {
console.error(signedURLResult.failure)
setIsLoading(false) // Set loading state to false
return
}
const { url } = signedURLResult.success
// console.log({ url })
try {
await fetch(url, {
method: "PUT",
headers: {
"Content-Type": selectedFile.type,
},
body: selectedFile,
})
console.log({ url })
} catch (error) {
console.error("Error uploading large file:", error)
setIsLoading(false) // Set loading state to false
} finally {
setIsLoading(false) // Set loading state to false when upload is complete
}
}How can I have the file that is just uploaded by the user sent to the backend? I have another function to upload a file that is smaller, can I just pass a url or something similar?