You are here

public function BackupMigrateDropboxAPI::list_folder in Backup and Migrate Dropbox 7.3

Same name and namespace in other branches
  1. 7.2 backup_migrate_dropbox.dropbox_api.inc \BackupMigrateDropboxAPI::list_folder()

Returns the contents of a Dropbox folder.

@link https://www.dropbox.com/developers/documentation/http/documentation#file... Dropbox API /list_folder

Parameters

string $folder:

Return value

object[] A list of file metadata of the files in the folder.

Throws

RuntimeException

File

./backup_migrate_dropbox.dropbox_api.inc, line 252

Class

BackupMigrateDropboxAPI
BackupMigrateDropboxAPI contains all the details about the Dropbox api, authorization calls, endpoints, uris, parameters, error handling, and split requests for large uploads/downloads

Code

public function list_folder($folder) {

  // Note, I once got this message: Dropbox error: Error in call to API
  // function "files/list_folder": request body: path: Specify the root folder
  // as an empty string rather than as "/". So we handle that case here.
  if ($folder === '/') {
    $folder = '';
  }

  // Simple listing: using Dropbox defaults:
  // - Not recursive.
  // - No deleted files.
  // - Include mounted files (the app folder is a mounted folder).
  $parameters = [
    'path' => $folder,
    'include_non_downloadable_files' => TRUE,
  ];
  $response = $this
    ->send_message('api', 'files/list_folder', $parameters);
  $files = $response->entries;
  while ($response->has_more) {
    $parameters = [
      'cursor' => $response->cursor,
    ];
    $response = $this
      ->send_message('api', 'files/list_folder/continue', $parameters);
    $files = array_merge($files, $response->entries);
  }
  return $files;
}