Overview

DropBox refers to any call to get a listing or inspect properties of a Directory or File as getting metadata. The SharpDropBox Client exposes the ability for you to set various additional parameters, but this is generally not needed. This library also uses Sterling DB internally to cache calls (which will limit the amount of data and calls to the DropBox service --there is a limit on how many calls you can make on a daily basis). You can override the cache as well as make a call and ensure that it only uses the cache.

Before Getting a Directory

Before you can get a directory you should make sure that you are logged in. Please review the documentation article on Logging in.

Getting a Directory Listing

To get the root directory (or any other Directory), do this:
  // You can provide any of the DropBoc Parameters in your call (in this example we are passing "list=true" which means we want to get the contents of the directory
  // That first value is the path you want to look at (you can look at 1 subdirectory at a time
  var pathToGet = ""; // This would get the root
  dbxApp.ListDirAndContents(pathToGet, new List<string>(), (obj) =>
  {
    if (obj.Error != null)
    {
        // obj.Error is the exception we got (the InnerException is the actual one coming back from the API -- if there was one.. it might be an error from DropBox)
    }
    else
    {
        // The obj param coming from the callback has the following additional properties:
        //   Path - The Original Path that you called the routine with
        //   Cached - Indicates that nothing changed since the last time you looked at this path (so the result was built based on the cache).. the last return might have happened 3 sessions ago
        //   Dictionary - This contains the name/values pairs coming back in the JSON returned by the service (useful if there is something you want to look at and tweak
        //   DirInfo - An strongly typed object of DBoxListing
        //         Contents - contains a list of DBoxListing items inside of the path you provided
        //         FullPath - contains the full path to this folder/file
        //         Hash - contains a Checksum (used internally by the API pass to DropBox which if the server copy matches we'll get a response that means use the cached version
        //         Icon - Icon to use (DropBox has a library of suggested icons that you can use to identify a file)
        //         IsDirectory - returns true if this is a directory
        //         LastModified - returns the last modified date for the file or directory
        //         Name - Just the file name (so it could be bound to a listbox or some other list control)
        //         Root - Whether this file exists in the "sandbox" or within the "DropBox" (there is a property you can set to change which you are working with
        //                    (Typically you will want to work with the main "DropBox")
        //         Size - Size of the file (0 for directories) as a string
        //         SizeInBytes - Size of the file as a long
        //         ThumbnailExists - Indicates if DropBox has a Thumbnail photo for this file 
    }
  });

Getting a Directory Listing Only Using the Cache


var pathToGet = ""; // This would get the root
   var obj = dbxApp.GetLastListingResultspathToGet);
    if (obj != null)
    {
        // The obj is an instance of DBoxListing
    }

Getting a Directory Listing Bypassing the Cache

At this time we don't have a way to do this. One thing you could do is swap out the ISterlingDbCache optional argument in the constructor for an instance of NoDbCache which will only use the REST calls and WILL CACHE NOTHING (be cautious with this)

Notes

There is a property of the DropBoxApp object called "MimicDropBoxFileSystemLocally" which is a boolean value. The library tries to "hide" its subdirectories from the PSDirectory/PSDirectoryInfo facades. If you don't want this to happen (maybe you sync all your files on load and just want to work locally), then you will want to have this value set to true.

The PSFile/PSFileInfo/PSDirectory/PSDirectoryInfo classes mimic the System.IO.File/FileInfo/Directory/DirectoryInfo classes. The "PS" stands for "Persisted Storage" which is one of the names that is used to refer to the IsolatedStorage mechanism. This was chosen over the "IS" prefix because any construct starting with "I" is generally expected to be an interface. To avoid confusion/conflicts, it was decided that a prefix would be helpful and avoids conflicts when both the "System.IO" and "System.IO.IsolatedStorage" namespaces are referenced via an Import/Using in the class.

Last edited Jan 19, 2011 at 9:29 AM by DevTheo, version 4

Comments

No comments yet.