Skip to content

Commit

Permalink
use special content type when application/json to avoid parsing probl…
Browse files Browse the repository at this point in the history
…ems when uploading
  • Loading branch information
peetucket committed Jun 8, 2023
1 parent 2fb0114 commit a7c9a71
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/jobs/deposit_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def build_file_metadata(blobs_map)
end

def clean_content_type(content_type)
# Invalid JSON files uploaded through H2 will trigger 400 errors in sdr-api since they are parsed
# and rejected. The work around is to change the content_type in H2 for any JSON files to something
# specific that will be changed back to application/json after upload is complete.
# There is a similar change in sdr-api to change the content_type back. See https://github.com/sul-dlss/happy-heron/issues/3075
return 'application/x-stanford-json' if content_type == 'application/json'

# ActiveStorage is expecting "application/x-stata-dta" not "application/x-stata-dta;version=14"
content_type&.split(';')&.first
end
Expand Down

0 comments on commit a7c9a71

Please sign in to comment.