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

File form redirection #520

Open
cs0511 opened this issue Mar 18, 2021 · 0 comments
Open

File form redirection #520

cs0511 opened this issue Mar 18, 2021 · 0 comments

Comments

@cs0511
Copy link

cs0511 commented Mar 18, 2021

I have a form with file field and remote: true.

The request format of this form is ["application/javascript", "application/x-javascript"].

On backend, I check user's permission, and redirect to another url.

But, for somehow, the new request(the redirected url) format is changed to ["application/xhtml+xml"].

If I remove the file field of the form and submit, the new request format will be kept, which is still ["application/javascript", "application/x-javascript"].

Started POST "/s3_objects" for ::1 at 2021-03-19 07:50:44 +0800
Processing by S3ObjectsController#create as JS
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"WL+YNfGcSbunkL9L1n9sxiaj5wb6pn76TW0rr2yjg12OAI2Ukm7XMEAE7HcjRLdxEA9xppGrVqym6x8tziWlAg==", "s3_object"=>{"name"=>"Screen Shot 2021-03-16 at 7.59.20 AM.png", "description"=>"", "test_at"=>"", "folder_id"=>"142", "file"=>#<ActionDispatch::Http::UploadedFile:0x00007fe575392328 @tempfile=#<Tempfile:/var/folders/2c/_xjwwtjd0gj9ch2384jr77kw0000gn/T/RackMultipart20210319-8891-sfrrd3.png>, @original_filename="Screen Shot 2021-03-16 at 7.59.20 AM.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"s3_object[file]\"; filename=\"Screen Shot 2021-03-16 at 7.59.20 AM.png\"\r\nContent-Type: image/png\r\n">}, "remotipart_submitted"=>"true", "X-Requested-With"=>"IFrame", "X-HTTP-Accept"=>"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"}


Redirected to http://localhost:3000/subscriptions/trial_expired
Filter chain halted as :check_subscription! rendered or redirected
Completed 302 Found in 76ms (ActiveRecord: 55.8ms)


Started GET "/subscriptions/trial_expired" for ::1 at 2021-03-19 07:50:44 +0800
Processing by SubscriptionsController#trial_expired as HTML

I see this gem does a special process for file field, https://github.com/rails/jquery-ujs/blob/master/src/rails.js#L502,

Is it by design that the request format is changed?

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

No branches or pull requests

1 participant