Skip to content

Commit 80b5748

Browse files
committed
方法返回值调整
1 parent ce3c88c commit 80b5748

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ $upyun = new UpYun('bucketname', 'username', 'password', UpYun::$ED_TELECOM);
3131
````
3232
$upyun->mkDir('/demo/');
3333
````
34-
创建成功返回 `True`,否则抛出 `UpYun`
34+
目录路径必须以斜杠 `/` 结尾,创建成功返回 `True`,否则抛出异常
35+
36+
### 删除目录或者文件
37+
````
38+
$upyun->delete('/demo/');
39+
$upyun->delete('/demo/demo.png');
40+
````
41+
删除成功返回True,否则抛出异常
3542

3643
## 异常处理
3744

upyun.class.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function writeFile($path, $file, $opts = NULL) {/*{{{*/
125125
if (!is_null($this->_file_secret)) array_push($opts, self::$CONTENT_SECRET . " {$this->_file_secret}");
126126
}
127127

128-
$this->_do_request('PUT', $path, $opts, $file);
128+
return $this->_do_request('PUT', $path, $opts, $file);
129129
}/*}}}*/
130130

131131
/**
@@ -143,11 +143,10 @@ public function readFile($path, $file_handle = NULL) {/*{{{*/
143143
* 获取目录文件列表
144144
*
145145
* @param string $path 查询路径
146-
* @param string $format 返回数据格式
147146
*
148147
* @return mixed
149148
*/
150-
public function getList($path, $format = NULL) {/*{{{*/
149+
public function getList($path) {/*{{{*/
151150
$rsp = $this->_do_request('GET', $path);
152151

153152
$list = array();
@@ -169,12 +168,7 @@ public function getList($path, $format = NULL) {/*{{{*/
169168
}
170169
}
171170

172-
if (is_null($format)) {
173-
return $list;
174-
}
175-
elseif ($format == 'json') {
176-
return json_encode(array('data' => $list));
177-
}
171+
return $list;
178172
}/*}}}*/
179173

180174
/**
@@ -193,15 +187,11 @@ public function getFolderUsage($path) {/*{{{*/
193187
* 获取文件、目录信息
194188
*
195189
* @param string $path 路径
196-
* @param string $format 返回数据格式
197190
*
198191
* @return mixed
199192
*/
200-
public function head($path, $format = NULL) {/*{{{*/
193+
public function head($path) {/*{{{*/
201194
$rsp = $this->_do_request('HEAD', $path);
202-
if ($format == 'json') {
203-
return json_encode($rsp);
204-
}
205195

206196
return $rsp;
207197
}/*}}}*/
@@ -299,11 +289,15 @@ protected function _do_request($method, $path, $headers = NULL, $body= NULL, $fi
299289
if ($method == 'GET' && is_null($file_handle)) {
300290
return $body;
301291
}
302-
elseif ($method == 'HEAD') {
303-
//return $this->_get_headers_data(substr($response, 0 , $header_size));
304-
return $this->_getHeadersData($header_string);
292+
else {
293+
$data = $this->_getHeadersData($header_string);
294+
return count($data) > 0 ? $data : true;
305295
}
306-
return True;
296+
//elseif ($method == 'HEAD') {
297+
// //return $this->_get_headers_data(substr($response, 0 , $header_size));
298+
// return $this->_getHeadersData($header_string);
299+
//}
300+
//return True;
307301
}
308302
else {
309303
$message = $this->_getErrorMessage($header_string);

0 commit comments

Comments
 (0)