Closed msdemlei closed 3 months ago
It could also check for Content-Disposition
if any of the services return it which in this case it does:
Content-Disposition: attachment; filename="red_nh240090.fits.gz"
. That would avoid the guesswork.
On Thu, Jun 13, 2024 at 04:15:21PM -0700, Adrian wrote:
I could also check for
Content-Disposition
if any of the services return it which in this case it does:Content-Disposition: attachment; filename="red_nh240090.fits.gz"
. That would avoid the guesswork.
I'm not against that, though the current behaviour of using the image title actually yields "better" results in this case. Anyway, I'd say that's a different (and potentially mildly breaking) change that should not be mixed up with the current bug fix.
Consider this code:
At this moment, this will result in a file Maidanak_Q2237+0305_2004-08-24_00:00:00_Johnson_R-1.None (or somesuch) on disk; the extension .None is really suboptimal.
The reason extension inference fails is that dal.mimetype.mime2extension, probably for reasons lost in time, turns the media type to a bytestring before passing it on to the built-in module mimetypes. Passing in a string fixes that and yields a .fits (on systems with suitable mime.types), as expected.