Skip to content
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

Adding a check for multipart forms #43

Merged
merged 1 commit into from
May 14, 2021
Merged

Adding a check for multipart forms #43

merged 1 commit into from
May 14, 2021

Conversation

jwoertink
Copy link
Member

Fixes #12

This one was kind of wild, and I may have gone a little overboard. Here's what the end result looks like:

Screen Shot 2021-05-13 at 8 37 04 PM

This will display the request body exactly as it normally would, except for the uploaded file is replaced with a placeholder <Lucky::UploadedFile. I wanted this to look like it was an instance to sort of give you an idea of where to look for more docs when figuring out these uploaded files.

Without this check, uploaded files that are plain text actually work fine provided they have utf8 safe chararset. When it comes to binary files like images, these will contain some invalid encoding characters so when you call request.body.to_s, it raises an error. Since we store the request body in to the database, we don't want to store the entire file. Instead, we're storing everything but the file, and just leaving a placeholder of what file you were uploading.

Copy link
Member

@matthewmcgarvey matthewmcgarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🎉

@jwoertink jwoertink merged commit a56087d into master May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request tracking does not handle non-UTF-8 encoded strings (file uploads)
2 participants