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 年前檢視次數 201 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南