Skip to content

File form redirection #520

Open
Open
@cs0511

Description

@cs0511

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions