cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DBFile Mime Type?

DBFile Mime Type?

Stuart T.
New member | Level 1

Is there any way to get the mime-type of a DBFile? Ideally, it'd be nice to query from the DBFileInfo so I can know before I download it. But if that's not possible, can I get it from a file I've downloaded? I'm using the iOS Sync API

8 Replies 8

Greg-DB
Dropbox Staff

The Sync SDK doesn't currently offer the mime type for DBFile, but I'll be sure to pass this along as a feature request.

One thing you may want to do is maintain a mapping of file extension to type and use that against the returned file extension though. For example, we have a list of groupings here:

https://www.dropbox.com/developers/reference/devguide

Steve M.
Dropbox Staff

To add a little color here, what Greg suggests is all that Dropbox does anyway. We don't store any sort of MIME type with the file; we just look at the file extension. So there's no advantage to getting this information from Dropbox; just pick your favorite list (e.g. from a web server) and map the extensions yourself.

Stuart T.
New member | Level 1

So Dropbox determines the MIME type entirely by file extension? Is that ever a problem, because the file extension doesn't guarantee file type?

Steve M.
Dropbox Staff

Yes, that's what Dropbox does. It's true that file extension doesn't guarantee file type. Can you think of something that does guarantee the file type?

Stuart T.
New member | Level 1

I suppose any solution is a lookup so maybe it doesn't guarantee, but previously we were using an iOS library called MagicKit which uses libmagic. However, I was hoping to get rid of it as it is causing some issues and appears to no longer be supported.
https://github.com/aidansteele/MagicKit

Steve M.
Dropbox Staff

Libmagic guesses based on the file contents. We're unlikely to take that approach... you could do something similar by just downloading the first portion of the file (a hundred bytes?), since most of the file type markers that this kind of library look for are located in the header of the file.

What's the specific scenario for your app? Are you frequently seeing files with the "wrong" extensions? In any case, Dropbox itself isn't going to be able to help you here. We don't do any sniffing of file content to try to guess the MIME type.

Stuart T.
New member | Level 1

Steve,

Well, I guess if I decide it's necessary to do any sniffing, I can do that on my own to verify file types, I guess I just assumed there would be occasional issues with relying on extension or if I file is missing an extension.

But it would great if Dropbox is already doing a mapping a file extension to type that DBFileInfo still provided that information. Sure it could be done in the app but it's just additional logic that I would imagine is common in many apps.

Thanks for your help Steve!

Steve M.
Dropbox Staff

Understood. We're tracking this as a feature request.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Steve M. Dropbox Staff
  • User avatar
    Stuart T. New member | Level 1
What do Dropbox user levels mean?