Can I search/get file by using File ID in Dropbox V2 API? - dropbox

I'm using Dropbox V2 APIs (C#) to get files/folders from Dropbox account. I am able to fetch particular file/folder by using its specific path. I wanted to know whether there is any way I can fetch file/folder by using ID?

This depends on exactly which operation(s) you're referring to. For example, downloading files and getting metadata for files or folders support specifying file IDs:
https://www.dropbox.com/developers/documentation/http/documentation#files-download
https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata
You would specify the path as a string like "id:a4ayc_80_OEAAAAAAAAAYa".
Searching and listing folders currently do not support this though:
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
https://www.dropbox.com/developers/documentation/http/documentation#files-search
The same applies to the corresponding methods in the SDKs.
Edit: list_folder and search now do support file IDs.

Related

Dropbox v2 web service to retrieve children of a folder is not returning "size" metadata for folders

I am integrating Dropbox in my application. I am able to retrieve child folders of a folder in Dropbox using "https://api.dropboxapi.com/2/files/list_folder" web service. But the data that is being returned doesn't contain size data for folders. Is there any way to retrieve size data for folders in Dropbox?
No, the Dropbox API doesn't report the size of a folder. You would need to compute it yourself, presumably by using /list_folder (with "recursive": true). I'm assuming the definition you have in mind is "the sum of the sizes of all files contained within the folder, recursively."

How to design RESTful API for hierarchical entities

I'm designing RESTful API for file storage and having problems with finding the best way to organize URL's to actions.
Files can be grouped to folders but it is needed to be able to get all the files.
Guidelines suggests to use the following url to get files for specific folder.
GET /folders/{folderName}/files
But what should be used to just get all files? GET /files or GET /folders/files?
Also Google Drive has somewhat similar functionality and they use diifferent approach
GET files/{folderName}/children
As you've noticed this can range from one API designer to another.
If I was facing this problem I would want to consider all use cases and figure out what works best.
It looks like the following would meet your needs:
GET / Retrieves all files and folders
GET /{folderId} Retrieves all contents of said folderId (folders and files)
GET /{fileId} Retrieves the file
GET /{folderId}/{folderId} Same as above, but for nested folder
GET /{folderId}/{folderId}/{fileId} Retrieves the file
this pattern can continue for however nested the file structure is (note there is a limit on URL length)
Then if you have a unique requirement such as all you just create a new api endpoint.
GET /files/ Retrieves all files
GET /files/?filter="*.txt" Retrieves all text files
So to answer your EXACT question of:
But what should be used to just get all files? GET /files or GET
/folders/files
I would lean towards /files instead of /folders/files. /folders/files does not make much sense as an api consumer.

Is it possible to know the folder content? OneDrive

I wanna try OneDrive Api for Android and I was taking a look at the methods and possibilities this Api offers on this link and this other one but I don't see any way of listing the files a folder contains.
My App would need to upload some files to OneDrive, always using the same folder as root, say /MyFolder. The problem is that it only knows this root folder and all its content must be found out by means of recursive calls, that is, I list the files contained in /MyFolder and check if it's a folder or a file and in the first case list the files again it contains and so on.
Am I missing something or this Api doesn't provide such thing?
The Json object returned for a query against a Folder should contain a "data" property that is an array of children for the folder. You can see this in the interactive SDK (http://isdk.dev.live.com/dev/isdk/default.aspx) by playing with the "Reading Folder Properties" API.

Office 365 MyFiles API - How to get the direct children in the root of the One Drive folder

I'm trying to work with the new summer release of the Office 365 API tool for Visual Studio 2013 (update 3). It works fine except one problem I've encountered which can be called also a missing functionality.
I found no reasonable way to retrieve the direct children of the root folder from my One Drive for business Document Library using the newly added SharePointClient library.
The API call of SharePointClient.Files will retrieve all the files and folders from the whole document library including sub-folders. So in order to get only the direct children I have to page through all the documents and folders and analyze their URL. This is not acceptable for my application scenario. For a sub-folder I can get the direct children like this: SharePointClient.Files["<folder_id>"].ToFolder().Children This is what I need but it can't be applied to the root folder.
I've tried to use the REST API directly and similarly the request GET ../_api/files will retrieve all files and folders in the default document library and I found no simple way to list only the direct children of the root. Also there is no convenient way to get the path or GUID of the default document library which the SharePointClient.Files automatically uses.
Parsing the result XMLs of the REST API calls I may get the GUID of the default document library, that will let me use a different REST API to list files and folders separately for the root folder, but these calls results in a different XML schema from that used by SharePointClient. This means that to get only the direct children of the root I would have to re-implement the whole SharePointClient library.
If anybody has some good advice I'll be very thankful.
I just ran into the same issue - hopefully this will be remedied before the release version of the api tools. Here is what I've done to get only the root folder content:
[Create your spClient = SharePointClient]
var allFiles = await spClient.Files.ExecuteAsync();
var rootFiles = allFiles.CurrentPage.Where(i => !i.Id.Contains("/"));
You lose the IPagedCollection wrapper and you may need to get more than the 'CurrentPage' to see all files but this is the best workaround I've found. I'm then able to you the 'ToFolder()' method you mentioned above to list content of sub-folders.

How can i get file's properties for a file in OneDrive?

I am using the REST API for OneDrive. I have a name of a file in the users storage. I want to obtain the properties for this file. According the documentation file's properties can be retrieved
if you have the file ID.(http://msdn.microsoft.com/en-us/library/dn659731.aspx) So I need the file ID and the only way I see to obtain it is to search the whole storage which is really unnecessary.
Is there a way to find properties of a file(with a known name) with a single request to the service?
Ideally the API would support access by path which would do what you require (assuming you have the full path and not just the name). Unfortunately, to my knowledge that isn't supported.
There is a heavy handed approach that may work for you though - you can use the search capabilities of the API to find files with the name you specify:
GET /[userid]/skydrive/search?q=MyVideo.mp4
The documentation is available at the link below:
http://msdn.microsoft.com/en-us/library/dn631847.aspx