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

add base64 support to multipart parser #3395

Merged
merged 9 commits into from
Oct 8, 2019
26 changes: 25 additions & 1 deletion modules/vba_documents/lib/vba_documents/multipart_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

require 'vba_documents/upload_error'

# TODO: add support for base64 encoding
module VBADocuments
class MultipartParser
LINE_BREAK = "\r\n"

def self.parse(infile)
if base64_encoded(infile)
create_file_from_base64(infile)
else
parse_file(infile)
end
end

def self.parse_file(infile)
File.open(infile, 'rb') do |input|
validate_size(input)
lines = input.each_line(LINE_BREAK).lazy.each_with_index
Expand All @@ -27,6 +34,23 @@ def self.parse(infile)
end
end

def self.base64_encoded(infile)
content = File.read(infile)
content.start_with?('data:application/pdf;base64,')
bastosmichael marked this conversation as resolved.
Show resolved Hide resolved
end

def self.create_file_from_base64(infile)
content = File.read(infile)
FileUtils.mkdir_p '/tmp/vets-api'
contents = content.sub %r{data:((pdf|application)/.{3,}),}, ''
decoded_data = Base64.decode64(contents)
filename = "temp_upload_#{Time.zone.now.to_i}.pdf"
File.open("/tmp/vets-api/#{filename}", 'wb') do |f|
f.write(decoded_data)
end
parse(File.open("/tmp/vets-api/#{filename}"))
end

def self.validate_size(infile)
unless infile.size.positive?
raise VBADocuments::UploadError.new(code: 'DOC107',
Expand Down
277 changes: 277 additions & 0 deletions modules/vba_documents/spec/fixtures/valid_multipart_base64_pdf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
data:application/pdf;base64,LS0xN2RlMWVkOGYwMTQ0MmIyYTJkN2E5MzUwNjMxNGI3Ng0KQ29udGVudC1E
aXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJjb250ZW50IjsgZmlsZW5h
bWU9ImNvbnRlbnQiDQpDb250ZW50LVR5cGU6IGF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wIG4gCjAwMDAwMTEyMDggMDAwMDAgbiAKMDAw
MDAxMTIzNSAwMDAwMCBuIAowMDAwMDExMjc3IDAwMDAwIG4gCjAwMDAwMTEy
OTYgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSAyMSAvUm9vdCAxMSAwIFIg
L0luZm8gMSAwIFIgL0lEIFsgPDVmMzFkZmZkYzI0MzA3Zjg4ZWZlZTY4NjNh
ZDAwN2NjPgo8NWYzMWRmZmRjMjQzMDdmODhlZmVlNjg2M2FkMDA3Y2M+IF0g
Pj4Kc3RhcnR4cmVmCjExNDYwCiUlRU9GCg0KLS0xN2RlMWVkOGYwMTQ0MmIy
YTJkN2E5MzUwNjMxNGI3Ng0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1k
YXRhOyBuYW1lPSJtZXRhZGF0YSI7IGZpbGVuYW1lPSJtZXRhZGF0YSINCkNv
bnRlbnQtVHlwZTogYXBwbGljYXRpb24vanNvbg0KDQp7InZldGVyYW5GaXJz
dE5hbWUiOiAiSmFuZSJ9DQotLTE3ZGUxZWQ4ZjAxNDQyYjJhMmQ3YTkzNTA2
MzE0Yjc2LS0NCg==

10 changes: 10 additions & 0 deletions modules/vba_documents/spec/lib/multipart_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,15 @@
expect(error.detail).to eq('Empty payload')
end
end

it 'handles a base64 payload' do
valid_doc = get_fixture('valid_multipart_base64_pdf.txt')
result = described_class.parse(valid_doc)
expect(result.size).to eq(2)
expect(result).to have_key('metadata')
expect(result['metadata']).to be_a(String)
expect(result).to have_key('content')
expect(result['content']).to be_a(Tempfile)
end
end
end