Whitelist fields in direct POST without requiring them to be in the form

0

I have a form that is doing a direct to S3 post. I have whitelisted the miscellaneous fields on the form, other than the file field, like text boxes, so that AWS won't reject the POST, using allow_any:
allow_any: %w(title description client_selectable clients[])

My problem is that fields like client_selectable (a checkbox) and clients[] (a select tag) don't send any form data if the checkbox is not checked or nothing selected in the select list. AWS appears to require that the fields I specify with allow_any to be there. I cannot understand why that is so. I can work around it with using hiddens, but it would be much cleaner if I knew how to tell AWS to allow those fields but don't require them.

Help?

Edited by: JasonSr on Apr 23, 2020 4:39 AM

JasonSr
질문됨 4년 전200회 조회
1개 답변
0

Did it another way. I just named all my custom fields in the form x-ignore-* and then I also have an x-ignore-post-upload-url which is the action my form submit ultimately goes to. So, when the xhr request completes sending the file to AWS, I do an ajax call to that action and include my form fields as data in the xhr request to my controller.

In other words, not using the allow_any policy at all.

Edited by: JasonSr on Apr 23, 2020 6:29 AM

JasonSr
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠