Closed fenos closed 9 months ago
@Murderlon i think it makes a lot of sense to also pass the parsed Metadata
in the namingFunction
as an optional second param for example:
function namingFunction(req, metadata) {
if (!metadata) {
throw new Error('must provide metadata')
}
// validate metadata
return metadata.fileName
}
Sounds good 👍
We can add the metadata
argument in this PR as well
Done 🎉
I'll do a release tomorrow.
This small PR simply allows error propagation in the namingFunction.
Currently, if an error is thrown from the
namingFunction
the error is swallowed and a 500 error code is returned. This behavior is not ideal, in my use case I rely on themetadata
in order to create a valid uploadID.For this reason the
metadata
is validated in the naming function. If some of the fields don't pass the validation instead of returning a 400 status code, the application returns a non-ideal 500