Skip to content

Binary Data not being stripped out on multipart upload #239

@jeffutter

Description

@jeffutter

I spent a few hours today trying to figure out why I was getting JSON encoding errors on my multipart-upload post doc specs. I eventually found an issue here: #202 detailing that it should be stripped out and replaced with [upload data]. I am super glad that rspec_api_documentation handles this for me, as every attempt I tried to do on my own to strip the data out via regex was coming up short.

Now that I know rspec_api_documentation was supposed to handle this form. I am still running into an issue where it is not properly stripping. I have have tracked it down to this line

"CONTENT_TYPE" => request_headers["Content-Type"],

When my test hits that line I have no Content-Type header, I have a Content_type header.

My spec looks roughly like this:

post '/photo/create' do
  let(:profile) { create(:profile) }
  let(:basic) { "Basic #{Base64.encode64(profile['token'])}:" }
  let(:event) { create(:event) }

  header "Authorization", :basic
  header "Content-Type", "multipart/form-data"

  parameter :file, "Photo File"
  parameter :original_filename, "Original Photo Filename"

  let(:file) { Rack::Test::UploadedFile.new('spec/fixtures/files/file.jpg') }
  let(:original_filename) { 'file.jpg' }

  example_request "Create a photo" do
    expect(status).to eq 200
  end
end

I can look into this more tomorrow. I wanted to drop the issue here though incase someone knew off hand what was going on.

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