cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

DBFile Mime Type?

New member | Level 1
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
Highlighted

Re: DBFile Mime Type?

Dropboxer
Dropboxer

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

Highlighted

Re: DBFile Mime Type?

Dropboxer
Dropboxer

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.

Highlighted

Re: DBFile Mime Type?

New member | Level 1
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?

Highlighted

Re: DBFile Mime Type?

Dropboxer
Dropboxer

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?

Highlighted

Re: DBFile Mime Type?

New member | Level 1
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

Highlighted

Re: DBFile Mime Type?

Dropboxer
Dropboxer

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.

Highlighted

Re: DBFile Mime Type?

New member | Level 1
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!

Highlighted

Re: DBFile Mime Type?

Dropboxer
Dropboxer

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

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?