How can I download and open a .dmg file using cocoa or applescript
+3
A:
Try NSURLDownload or NSURLConnection. Google also answers the question handily if you leave out the "dmg" part and go more generic.
Joshua Nozzi
2010-06-24 16:45:13
well the big thing is is that it has to open the DMG file
Matt S.
2010-06-24 17:01:46
When the file is done, ask the shared NSWorkspace to -openFile: ...
Joshua Nozzi
2010-06-24 17:22:16
Matt S.: Downloading a file and opening a file are separate tasks with separate solutions.
Peter Hosey
2010-06-25 07:55:28
A:
As @Joshua said, you can use NSURLDownload or NSURLConnection to retrieve the file. To mount it, run an NSTask
that executes hdiutil attach /path/to/downloaded/file.dmg
.
Dave DeLong
2010-06-24 17:22:23
Ouch. Seems a bit heavy-handed. Is there some advantage to using hdiutil versus opening the file with NSWorkspace?
Joshua Nozzi
2010-06-24 17:26:21
A quick test shows that, where UI is needed (the case of a password-protected dmg), you'd need to interact with the task to supply the password. Via NSWorkspace, you're prompted in the GUI as when opening with Finder.
Joshua Nozzi
2010-06-24 17:32:47