-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
files
function capturing empty input-file field.
#396
Comments
Looks like a bug, but could you share first what |
Hi, it's |
@tusharad could you please check whether previous versions of scotty have the same behaviour? I suspect not because the changes introduced in 0.22 move the files parsing behaviour to wai-extra. We don't even have a test for the "no files" case, fwiw. |
Thanks @tusharad for checking! This is odd and unintuitive behaviour, but I'm at least glad that it didn't appear in 0.22 . Question now is, what's the cause of this, and how do we fix it? |
Hi @ocramz, Upon investigating the I've provided two images illustrating the output of It appears that To address this, I propose a simple solution: apply a filter function after Here's the proposed modification within the
Please review and let me know if this approach aligns with your expectations. If approved, I'll proceed with creating a PR. Thank you! |
@tusharad Yes, this fix seems sensible but it's also a breaking change that should be documented as such. Happy to review your PR! |
…ot uploading any file.
… not uploading any file.
Situation
In my scotty application. I have a HTML form that takes an input file, which is a optional field. I am using
files
function to capture the file. I assumed that if user doesn't upload a file, thefiles
function would return an empty list. But it is returning a list containingFileInfo
type with fileName as"\"\""
.Question:
Is this the correct behaviour? My workaround is if the fileContent is empty, I will reject the file or can there be any better solution for
files
?When the list is empty:
Checkout full project code:
files
function code: https://github.com/tusharad/HaskRead/blob/25cdbe72fe2e8ba7297526de7644d0a503b22e3b/src/ScottyCrud/Handler.hs#L45HTML Form code: https://github.com/tusharad/HaskRead/blob/25cdbe72fe2e8ba7297526de7644d0a503b22e3b/src/ScottyCrud/HTML/Core.hs#L93
The text was updated successfully, but these errors were encountered: