Ejemplo n.º 1
0
 /**
  * Returns metadata for all files and folders whose filename matches the query string.
  *
  * See <a href="https://www.dropbox.com/developers/core/docs#search">/search</a>.
  *
  * @param string $basePath
  *    The path to limit the search to (UTF-8).  Pass in "/" to search everything.
  *
  * @param string $query
  *    A space-separated list of substrings to search for.  A file matches only if it contains
  *    all the substrings.
  *
  * @param int|null $limit
  *    The maximum number of results to return.
  *
  * @param bool $includeDeleted
  *    Whether to include deleted files in the results.
  *
  * @return mixed
  *    A list of <a href="https://www.dropbox.com/developers/core/docs#metadata-details>metadata
  *    objects</a> of files that match the search query.
  *
  * @throws Exception
  */
 function searchFileNames($basePath, $query, $limit = null, $includeDeleted = false)
 {
     Path::checkArg("basePath", $basePath);
     Checker::argStringNonEmpty("query", $query);
     Checker::argNatOrNull("limit", $limit);
     Checker::argBool("includeDeleted", $includeDeleted);
     $response = $this->doPost($this->apiHost, $this->appendFilePath("1/search", $basePath), array("query" => $query, "file_limit" => $limit, "include_deleted" => $includeDeleted));
     if ($response->statusCode !== 200) {
         throw RequestUtil::unexpectedStatus($response);
     }
     return RequestUtil::parseResponseJson($response->body);
 }