Merge pull request #1445 from betagouv/cellar_improve_range_query
CleverCloud Cellar Compatible range query
This commit is contained in:
commit
389760fc17
1 changed files with 9 additions and 6 deletions
|
@ -1,9 +1,12 @@
|
||||||
|
# Monkey patch ActiveStorage to make Range query compatible with CleverCloud Cellar
|
||||||
|
#
|
||||||
|
# FIXME : remove when better fix is available
|
||||||
ActiveStorage::Identification.class_eval do
|
ActiveStorage::Identification.class_eval do
|
||||||
def apply
|
private
|
||||||
# Monkey patch ActiveStorage to trust the user-submitted content type rather than determining
|
|
||||||
# it from the file contents, because Cellar does not seem to support the Range header
|
def identifiable_chunk
|
||||||
#
|
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |client|
|
||||||
# FIXME : remove when better fix is available
|
client.get(uri, "Range" => "bytes=0-4096").body
|
||||||
blob.update!(content_type: declared_content_type, identified: true) unless blob.identified?
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue