This is a Web App that will eventually run on Linux (and maybe macOS/Windows), so macOS only is not enough. Given it works for desktop macOS, I am unsure why Web macOS doesn’t work.
The Web App accepts uploaded files and needs to display the icon image to the user. Will it be fixed sometime?
For a web app, I would also recommend just having a collection of icons and using those. This would offer you a few benefits:
You can rely on it to work every time on every installation
You can be sure exactly what the icon you’re going to display is
You can serve the images from a CDN or static delivery system - this improves speed and the icon won’t have to be generated and sent to the browser for each file
NSImageMBS won’t work on Linux, LinuxIconMBS won’t work on Mac, you’ll need a different plugin for each platform - more code! Take the simple route for this one
The NSImageMBS suggestion above doesn’t work in a WebApp either. The below code gives a result for tempPicture every time in a Desktop app, but in a macOS Web App it returns nil for all 32 representations:
[code]Dim f As FolderItem = SpecialFolder.Documents
Dim n As NSImageMBS = NSWorkspaceMBS.iconForFile(f)
Dim tempPicture As Picture
Dim reps() As NSImageRepMBS = n.representations
For Each r As NSImageRepMBS In reps
n.removeRepresentation r
Dim nn As New NSImageMBS(r.pixelsWide, r.pixelsHigh)
nn.addRepresentation r
tempPicture = nn.CopyPictureWithMask
If tempPicture <> Nil And tempPicture.Width >= 512 Then
Exit
End If
Next[/code]
I’m hoping LinuxIconMBS will be able to help out on Linux. Is a GUI a requirement to get a file’s icon picture I would have thought it was stored in the OS with the file or in a library somewhere?
Sorry, but LinuxIconMBS doesn’t return a picture in Linux Mint (ie has a GUI) in a Web App either. In the code below (borrowed from the LinuxIconMBS example, tempPicture is always nil. I placed this in the Open event.
[code]Dim tempPicture As Picture
// icon for desktop folder
Dim f2 As FolderItem = SpecialFolder.Desktop
tempPicture = LinuxIconMBS.FileIcon(f2, 512)