You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parseFormData takes uploadHandler at the second arg, but since the function only takes one arg which is (fileUpload: FileUpload), it's hard to make it reusable.
To pull it outside of action, we have to do a higher order function gymnastics like this:
Also, it's not clear to me how I can return an extra value from uploadHandler.
For instance, I'm creating a DB record that keeps uploaded file's metadata, and would like to return upload.id which is only generated and accessible inside the handler function.
Also it can even receive multiple files in one request, which makes things even more complicated...
What is a suggested solution here?
exportasyncfunctionuploadHandler(id: string){returnasync(fileUpload: FileUpload)=>{letupload=awaitUpload.create({owner_id: id,name: fileUpload.name,})letstorageKey=`image-${upload.id}`awaitFileStorage.set(storageKey,fileUpload)returnFileStorage.get(storageKey)}}exportasyncfunctionaction({ request, params }){letformData=awaitparseFormData(request,awaituploadHandler(params.id))// how can I access upload.id(s) just generated?}
parseFormData
takesuploadHandler
at the second arg, but since the function only takes one arg which is(fileUpload: FileUpload)
, it's hard to make it reusable.To pull it outside of
action
, we have to do a higher order function gymnastics like this:This is fine, but I think it's unkind to less experienced users.
Until we figure out a better API, can we at least put this example in a visible place? The current README has a bug with referencing
user.id
.If I should create a PR for this, let me know.
Thanks for this great library!
The text was updated successfully, but these errors were encountered: