コード例 #1
0
 /**
  * Send our request
  *
  * @author Art <*****@*****.**>
  *
  * @param string       $url  Endpoint URL
  * @param string       $path Path to the target
  * @param Options|null $opts Any additional options
  *
  * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if
  *                                                                                  async is set to true and the
  *                                                                                  request interface if it is
  *                                                                                  set to false
  * @throws \GuzzleHttp\Exception\ClientException
  */
 public function send($url, $path, Options $opts = null)
 {
     $params = [Option::PATH => $path];
     if ($opts) {
         $params = array_merge($params, $opts->toArray());
     }
     return $this->sendAbstract('POST', self::HOST . '/' . self::API_VERSION . '/files/' . $url, ['headers' => ['Dropbox-API-Arg' => json_encode($params)]]);
 }
コード例 #2
0
 /**
  * Send the request
  *
  * @author Art <*****@*****.**>
  *
  * @param string       $url     The URL to send to. This will be prepended with the HOST and API version
  * @param array|string $path    The paths involved. Will be a string for most operations or an array for
  *                              move/copy operations
  * @param Options|null $options Additional options
  *
  * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if
  *                                                                                  async is set to true and the
  *                                                                                  request interface if it is
  *                                                                                  set to false
  * @throws \GuzzleHttp\Exception\ClientException
  */
 protected function send($url, $path, Options $options = null)
 {
     $body = is_array($path) ? $path : [Option::PATH => $path];
     if ($options) {
         $body = array_merge($body, $options->toArray());
     }
     return $this->sendAbstract('POST', self::HOST . '/' . self::API_VERSION . '/' . $url, ['headers' => ['Content-Type' => 'application/json'], 'body' => json_encode($body)]);
 }
コード例 #3
0
 /**
  * Send the request
  *
  * @author Art <*****@*****.**>
  *
  * @param string                                            $url  The URL to send to. This will be prepended
  *                                                                with the HOST, API version and "files/"
  * @param string                                            $path The path to upload the file to
  * @param string|resource|\Psr\Http\Message\StreamInterface $body The file contents. Can be a string, a fopen()
  *                                                                resource or an instance of StreamInterface
  * @param \Alorel\Dropbox\Options\Options|null              $opts Any additional, operation-specific options
  *
  * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if
  *                                                                                  async is set to true and the
  *                                                                                  request interface if it is
  *                                                                                  set to false
  * @throws \GuzzleHttp\Exception\ClientException
  * @see    ContentUploadOperation::HOST
  * @see    Operation::API_VERSION
  */
 protected function send($url, $path, $body, Options $opts = null)
 {
     $headers = ['Content-Type' => 'application/octet-stream', 'Dropbox-API-Arg' => []];
     $arg =& $headers['Dropbox-API-Arg'];
     if ($path) {
         $arg[Option::PATH] = $path;
     }
     if ($opts) {
         $arg = array_merge($arg, $opts->toArray());
     }
     $arg = $arg ? json_encode($arg) : '{}';
     $params = ['headers' => $headers];
     if ($body !== null) {
         $params['body'] = $body;
     }
     return $this->sendAbstract('POST', self::HOST . '/' . self::API_VERSION . '/files/' . $url, $params);
 }
コード例 #4
0
ファイル: Search.php プロジェクト: alorel/dropbox-v2-php
 /**
  * Perform the operation, returning a promise or raw response object
  *
  * @author Art <*****@*****.**>
  *
  * @param string             $query   The search query
  * @param string             $path    The folder to search
  * @param SearchOptions|null $options Additional options
  *
  * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if
  *                                                                                  async is set to true and the
  *                                                                                  request interface if it is
  *                                                                                  set to false
  * @throws \GuzzleHttp\Exception\ClientException
  */
 public function raw($query, $path = '', SearchOptions $options = null)
 {
     return $this->send('files/search', $path, Options::merge([Option::QUERY => $query], $options));
 }
コード例 #5
0
ファイル: Append.php プロジェクト: alorel/dropbox-v2-php
 /**
  * Perform the operation, returning a promise or raw response object
  *
  * @author Art <*****@*****.**>
  *
  * @param string|resource|\Psr\Http\Message\StreamInterface $data    The file contents. Can be a string, a fopen()
  * @param UploadSessionCursor                               $cursor  The upload session cursor
  * @param UploadSessionActiveOptions|null                   $options Additional operation options
  *
  * @return \GuzzleHttp\Promise\PromiseInterface|\Psr\Http\Message\ResponseInterface The promise interface if
  *                                                                                  async is set to true and the
  *                                                                                  request interface if it is
  *                                                                                  set to false
  * @throws \GuzzleHttp\Exception\ClientException
  */
 public function raw($data, UploadSessionCursor $cursor, UploadSessionActiveOptions $options = null)
 {
     return $this->send('upload_session/append_v2', null, $data, Options::merge($options, [Option::CURSOR => $cursor]));
 }