Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
Steven T.
11 years agoNew member | Level 2
Is it possible to load a small part of a file?
I'm using the Sync API on iOS. The app deals with a lot of large data files which have information in their header. I'd like to display this information (perhaps less than 1kb of data) to the user without having to download a file (anywhere up to 50mb and beyond). I can only find a way to load the entire file into an NSData but that would be too slow. Is there some way to load only the first part of a file?
I'd also like the possibility of creating and uploading thumbnails because Dropbox's servers aren't be able to create thumbnails for the files we use. Ideally we could upload a thumbnail in a common browser image file format (PNG, JPG or GIF for example) so that Dropbox could show users these thumbnails in other contexts.
11 Replies
Replies have been turned off for this discussion
- Greg-DB11 years ago
Dropbox Community Moderator
The Sync SDK doesn't currently offer support for downloading/accessing partial pieces of files, but I'll be sure to pass this along as a request.
The Core API /files (GET) endpoint itself does support Range Retrieval Requests though, so if you need this functionality you may want to consider using that directly instead:
https://www.dropbox.com/developers/core/docs#files-GET
I'll also file this as a request for a way to supply custom thumbnails.
- Steven T.11 years agoNew member | Level 2
Thanks for the quick answer. Is it possible to mix the Sync API and the Core API? Can I use the Sync API for authorisation are file operations and just use core for the GET with a range? I looked into using the Core API but the authorisation process appears to always use the browser and I prefer to let the user go through the Dropbox app if its installed.
- Greg-DB11 years ago
Dropbox Community Moderator
The authorization flow that uses the Dropbox app is built into the official SDKs. It's technically possible to use both the Core and Sync SDKs, but it's not easy. (It wasn't something we designed for since we didn't intend for both to be used in the same app. The basic idea would be to import the Sync SDK normally, and then import the Core SDK source. You'd then need to remove some OS X files and rename duplicate classes.)
In this case, I would like to recommend just using the Sync SDK, and manually making the Core API call using the access token, but unfortunately the Sync SDK doesn't currently expose the access token. (We do have that open as a feature request though.) Apologies I don't have a good solution here.
- Steven T.11 years agoNew member | Level 2
Thanks again for the quick response.
- Brendan D.11 years agoExplorer | Level 4
Is it possible to bypass the Dropbox Core API and use the new UIDocumentPickerViewController stuff in iOS 8 for exporting and importing documents from Dropbox? I use it already for downloading from Dropbox, but for uploading to Dropbox I'm still using the Core API. That might solve the problem with being able to use the Core API and the Sync API at the same time.
- Greg-DB11 years ago
Dropbox Community Moderator
I believe the official Dropbox for iOS app currently registers as a Document Picker with the following modes:
UIDocumentPickerModeImport
UIDocumentPickerModeExportToServiceIf those suits your use case you can certainly use those instead.
- Jeremy P.39 years agoNew member | Level 1
I have the same question, but with regard to the Core API, rather than the Sync API. I need to be able to read the first few lines of a file, in order to decide whether it is appropriate to download. In the Android version of my app I can do this with the Core API by using the DropboxAPI.getFileStream method, and using the returned DropboxInputStream to read just the first bit (4k, in my case) of the file, and then closing the DropboxInputStream. I can then examine the header information I have read, and if the file meets my conditions for downloading, I go ahead and download it using DropboxAPI.getFile.
I don't see any way in the iOS DropboxSDK world to do this kind of partial read. It looks like I am stuck with downloading the entire file with DBRestClient's loadFile:intoPath: method. Am I missing something here?
- Greg-DB9 years ago
Dropbox Community Moderator
Hi Jeremy, no, unfortunately the iOS Core SDK doesn't offer a way to do range/partials requests like this, but I'll be sure to pass this along as a feature request.
Note that it is open source though, so you could modify the source if/as desired.
- Jeremy P.39 years agoNew member | Level 1
Hi Gregory,
Thanks for the feedback. That's kind of what I expected.
I appreciate the open source suggestion, though I would rather rely on vanilla Dropbox SDK code than on my own home-brewed variant. Also, as far as I could see from the Dropbox Developer site, the only iOS interface that is open source is DBChooser, not the full DropboxSDK. But if the DropboxSDK code really is open source, I wouldn't mind browsing it. Can you point me to where the open source archives for the iOS DropboxSDK are available?
- Greg-DB9 years ago
Dropbox Community Moderator
Sure, the source for the iOS Core SDK is included in the download here:
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!