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
Assume a multipart form with the following fields:
csrf
projectId
files
With the current @hattip/multipart parsing you have no way to check the csrf, before processing the files. You also have no way to access the projectId in the handleFile function, which is tedious when you wanna include that projectId in the resulting file path. Currently the only way is to either provide csrf and projectId via headers or query parameters, or to store the files in a temporary directory.
Idea: add options to control the order of the parsing and to hook into fields. Also add the already processed fields as a second parameter of handleFile.
letprojectId='';constformData=awaitparseMultipartFormData(request,{// not all fields have to be in the order, missing fields will be processed at the endorder: ["csrf","projectId"],asynchandleField(name,value){if(name==='csrf'&&value!==PROPER_CSRF){thrownewError("Access denied");}if(name==='projectId'){projectId=value;}returnvalue;},asynchandleFile(info,fields){// access projectId via "fields", or via the "projectId" variable from above
...uploadthings}})
The text was updated successfully, but these errors were encountered:
Assume a multipart form with the following fields:
With the current
@hattip/multipart
parsing you have no way to check the csrf, before processing the files. You also have no way to access the projectId in thehandleFile
function, which is tedious when you wanna include that projectId in the resulting file path. Currently the only way is to either provide csrf and projectId via headers or query parameters, or to store the files in a temporary directory.Idea: add options to control the order of the parsing and to hook into fields. Also add the already processed fields as a second parameter of
handleFile
.The text was updated successfully, but these errors were encountered: