-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
The following file is not properly detected as image/x-canon-cr2:
https://realphotos.mypinata.cloud/ipfs/bafybeihzvorkcgtcg6yxgnhof7ifvqguf2yuvtko34shgxgz6eqdvpxlxq
Reference shell:
URL="http://silver-naval-alligator-759.mypinata.cloud/files/bafybeihzvorkcgtcg6yxgnhof7ifvqguf2yuvtko34shgxgz6eqdvpxlxq"; mime_head=$(curl -sI "$URL" | grep -i "^content-type:" | awk '{print $2}' | tr -d '\r'); [ -n "$mime_head" ] && echo "$mime_head" || { tmp=$(mktemp); curl -s --range 0-4095 "$URL" -o "$tmp"; file --mime-type -b "$tmp"; rm -f "$tmp"; }
# => image/x-canon-cr2Reproduce script:
#!/usr/bin/env ruby
require 'open-uri'
require 'marcel'
url = "http://silver-naval-alligator-759.mypinata.cloud/files/bafybeihzvorkcgtcg6yxgnhof7ifvqguf2yuvtko34shgxgz6eqdvpxlxq"
io = URI.open(url, "rb", content_length_proc: ->(len) { puts "Fetching #{len} bytes..." if len })
head = io.read(4096)
io.rewind
mime_type = Marcel::MimeType.for(StringIO.new(head), name: File.basename(url))
puts "Detected MIME type: #{mime_type}"Output:
Detected MIME type: image/tiff
Metadata
Metadata
Assignees
Labels
No labels