Class DropBoxFileSystem


public class DropBoxFileSystem extends FileSystem
Class for accessing the DropBox file system.
  • Constructor Details

  • Method Details

    • setCredentialsResolver

      public DropBoxFileSystem setCredentialsResolver(CredentialsResolver credentialsResolver)
      Sets the resolver supplying this file system's access token (Credentials.TOKEN) — resolved on each open(), never at construction, so rotated tokens are picked up on the next connection. When the resolved credentials don't contain a token, the constructor-supplied token is used.
      Overrides:
      setCredentialsResolver in class FileSystem
    • open

      public void open() throws DataException
      Opens a connection to the DropBox file system.
      Overrides:
      open in class Endpoint
      Throws:
      DataException
    • close

      public void close() throws DataException
      Closes the DropBox connection.
      Overrides:
      close in class FileSystem
      Throws:
      DataException
    • readFile

      public InputStream readFile(String folderName, String fileName) throws Throwable
      Reads the file in the specified DropBox folder. To specify a nested folder, use "/" as separator.
      Example:
      • readFile("folderOne", "fileName") - reads the file in folderOne folder
      • readFile("folderOne/folderTwo", "fileName") - reads the file in folderTwo which is under folderOne
      Parameters:
      folderName - the name of the folder
      fileName - the file name to read.
      Returns:
      an InputStream
      Throws:
      Throwable
    • readFile

      public InputStream readFile(String fileName) throws Throwable
      Reads the file in the DropBox root folder.
      Parameters:
      fileName - the file name to read.
      Returns:
      an InputStream
      Throws:
      Throwable
    • listFolder

      public List<Metadata> listFolder(String folderName) throws Throwable
      Returns an list of all DropBox files and folders belonging to the folderName. To specify a nested folder, use "/" as separator.
      Example:
      • listFolder("folderOne") - reads the contents in folderOne which is under the root folder
      • listFolder("folderOne/folderTwo") - reads the contents in folderTwo which is under folderOne
      Parameters:
      folderName - the folder name to read
      Returns:
      the contents as a List
      Throws:
      Throwable
    • listRootFolder

      public List<Metadata> listRootFolder() throws Throwable
      Returns a List of all DropBox files and folders in the root folder.
      Returns:
      the contents as a List
      Throws:
      Throwable
    • writeFile

      public OutputStream writeFile(String fileName) throws Throwable
      Writes the file to the DropBox File System. Throws a DataException if the file already exists.
      Parameters:
      fileName - the name of the file
      Returns:
      an OutputStream for writing
      Throws:
      Throwable
    • writeFile

      public OutputStream writeFile(String folderName, String fileName) throws Throwable
      Writes the file to the specified folder in the DropBox File System. Throws a DataException if the file already exists.
      Parameters:
      folderName - the destination folder of the file being written
      fileName - the name of the file
      Returns:
      an OutputStream for writing
      Throws:
      Throwable