コード例 #1
0
ファイル: Vdisk.php プロジェクト: slurin/Vdisk-File-Explorer
 /**
  * Uploads file data from a stream
  * Note: This function is experimental and requires further testing
  *
  * <br />对应API: {@link http://vdisk.weibo.com/developers/index.php?module=api&action=apidoc#files_put files_put}
  *
  * @todo Add filesize check
  * @param resource $stream A readable stream created using fopen()
  * @param string $toPath The destination filename, including path
  * @param boolean $overwrite Should the file be overwritten? (Default: true)
  * @param boolean $safe 是否使用https 默认为false
  * @return array
  */
 public function putStream($stream, $toPath, $overwrite = true, $safe = false)
 {
     $this->OAuth->setInFile($stream);
     $path = $this->encodePath($toPath);
     $params = array('overwrite' => $overwrite ? 'true' : 'false');
     $call = 'files_put/' . $this->root . '/' . $path . '?' . http_build_query($params);
     if ($safe) {
         $response = $this->fetch('PUT', self::CONTENT_SAFE_URL, $call);
     } else {
         $response = $this->fetch('PUT', self::CONTENT_URL, $call);
     }
     return $response;
 }