Where's the best place to get the hash of a file?
When users upload files to my app, I want to generate the md5 hash - where's the best place to hook into the uploadthing flow to do this?
Solution:Jump to solution
```ts
.onUploadComplete(async ({ metadata, file }) => {
console.log("file url", file.url);
const buffer = await fetch(file.url).then((f) => f.arrayBuffer());...
9 Replies
(using Next)
replace
Buffer.from("UThing")
with the file buffer (fetch it)Thanks, so it's best to do this in
onUploadComplete
?
Does the file get streamed to my server before uploadThing? Or is the request somehow redirected?Solution
something like this
Thanks, super useful 🙂
out of interest would there be a way to check the hash before it goes to uploadThing?
just trying to get the right mental model
let me check
most likely not
![No description](https://cdn.answeroverflow.com/1261297672531349534/Screenshot_2024-07-12_at_09.26.33.png)
thanks ser 🙂 really appreciate yourtime
^^