May 17, 2007
My DMG is Bwoken After Download!

Today we're ran into a rather obscure situation. Rosyna has created a bz2-compressed DMG image for the new beta of the next major update to FontCard, and when I went to download it, I've noticed that Safari downloads it as "fontcard-xxx.dmg.bz2". Needless to say, it tried to expand the bz2 file upon downloading, and then failed miserably on mounting the expanded DMG file with this error:

damaged-dmg.png

"WTF?", I thought. The file name in the URL was ending with "dmg" and not "dmg.bz2". Yes, the data inside of the DMG is compressed using bz2, but nobody should care about that.

So I tried to download the same file using FireFox, and all went just fine: the image downloaded, the file name never changed, and it mounted as it should. I've looked at the response our server been sending, and it was:

Content-Type: application/octet-stream

So what I am guessing is that Safari tries to guess the file type when it's not forcibly defined by the Content-Type; in this particular case, it looked in the file and noticed it is most likely a bz2 archive, so it safely appended the .bz2 extension to the file and continued the download, resulting in the hiatus described above.

So, we've made a tiny change to our .htaccess file, and guess what? Now all DMGs (including the one I just had problems with) download just fine. This also possibly explains why some of our users were having random issues with the DMG images they've downloaded. Perhaps in some cases Safari decided it's a zip archive (since we used to prepare our DMGs compressed with zip), expanding it before passing to the diskutil, making it fail in the end.

So, if you serve DMGs off your hosting, take a note on that. Luckily, the fix is simple (assuming your web host uses Apache):

Open or create a .htaccess file in the root of your Web directory, and put the following line in:

AddType application/x-apple-diskimage dmg

This instructs Apache to forcibly tell the visitors that files ending with "dmg" has a content type of application/x-apple-diskimage, which makes Safari behave as it should: skip the "guessing" part and pass the image where it belongs.

I'd like to say thanks to Mark Rowe for telling us the "right" MIME type. ;)

Digg This!

 Posted by slava at May 17, 2007 12:06 AM

Trackback Pings:

TrackBack URL for this entry:
http://www.unsanity.org/mt-tb.cgi/418.




Related:
Comments

Interesting, I had a big problem with this myself with Quicksilver. http://getqs.com downloads a .dmg.bz2 image for me in Safari, but not in Camino or Firefox. I read about the fix on Macupdate, but it still isn't fixed.

Posted by: ACoolie on May 17, 2007 1:10 PM

hiatus
a pause or gap in a sequence, series, or process

Suggested alternatives:

  • hubbub
  • hustle
  • havoc

—————

On another note, thanks for posting this. It'll come in handy if I ever find myself serving DMG files.

Posted by: Arden on May 19, 2007 5:33 PM

How can I get FruitMenu to show my real world IP address? Instead of 10.0.1.1 in my Apple Menu?

Posted by: Court Kizer on May 22, 2007 7:58 PM

I think I saw this same problem with the SourceForge download of the latest aMSN distribution. I'd thought they were just out of their vulcan minds and for some reason decided to distribute aMSN as a dmg.bz2 ;) (I have my Safari set not to auto-open things and so was just left with a dmg.bz2 file in the Finer. Of course, BOMArchive helper refused to decompress it.

Going to FireFox solved the problem of course so I never thought of it again until now.

Thanks for posting this useful stuff.
-Ken

Posted by: Ken on August 3, 2007 2:37 PM

please help me!Howe is opened dmg files?

Posted by: a.c. on August 24, 2007 9:01 AM

how do i play test server?? =)

Posted by: vincenzo on September 6, 2007 3:30 AM

I need download this file extension

Posted by: adrian estanciero on September 26, 2007 12:21 PM

I need download the extensions files

Posted by: adrian estanciero on September 26, 2007 12:28 PM

please can u provide me i need it

Posted by: Irene Agyapong on November 16, 2007 12:58 AM

where is the download pic

Posted by: john on April 25, 2008 6:11 PM
Post a comment
Keep comments on topic. If a comment is unrelated to this post, it may be removed or moderated.





Remember Me?

(you may use HTML tags for style)