Home >Backend Development >PHP Tutorial >七牛的源代码挑刺

七牛的源代码挑刺

WBOY
WBOYOriginal
2016-06-06 20:23:341238browse

https://github.com/qiniu/php-sdk/blob/master/examples/up.php
这里是七牛上传文件的源代码,截取部分如下

require_once DIR . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);
$bucket = 'Bucket_Name';
$token = $auth->uploadToken($bucket);
$uploadMgr = new UploadManager();
// 上传文件到七牛
$filePath = './php-logo.png';
$key = 'php-logo.png';
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
echo "\n====> putFile result: \n";
if ($err !== null) {

<code>var_dump($err);</code>

} else {

<code>var_dump($ret);</code>

}
?>

提几个问题
1.代码应该缩进
2.用词不当
$key = 'php-logo.png'; 这一行我感觉,不是密码的意识,密码已经在
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
应当是文件名的意识,应当用 $fname
3.作者为何不写英语注释?
请让我来修改一下

<code>require_once __DIR__ . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);
$bucket = 'Bucket_Name';
$token = $auth->uploadToken($bucket);
$uploadMgr = new UploadManager();
// upload file into qiniu
$filePath = './php-logo.png';
$fname = 'php-logo.png';
list($ret, $err) = $uploadMgr->putFile($token, $fname, $filePath);
echo "\n====> putFile result: \n";
if ($err !== null) {
    var_dump($err);
} else {
    var_dump($ret);
}</code>

?>

多高大上,白富美哈!!

这个问题已被关闭,原因:非技术提问的讨论型问题

回复内容:

https://github.com/qiniu/php-sdk/blob/master/examples/up.php
这里是七牛上传文件的源代码,截取部分如下

require_once DIR . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);
$bucket = 'Bucket_Name';
$token = $auth->uploadToken($bucket);
$uploadMgr = new UploadManager();
// 上传文件到七牛
$filePath = './php-logo.png';
$key = 'php-logo.png';
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
echo "\n====> putFile result: \n";
if ($err !== null) {

<code>var_dump($err);</code>

} else {

<code>var_dump($ret);</code>

}
?>

提几个问题
1.代码应该缩进
2.用词不当
$key = 'php-logo.png'; 这一行我感觉,不是密码的意识,密码已经在
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
应当是文件名的意识,应当用 $fname
3.作者为何不写英语注释?
请让我来修改一下

<code>require_once __DIR__ . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);
$bucket = 'Bucket_Name';
$token = $auth->uploadToken($bucket);
$uploadMgr = new UploadManager();
// upload file into qiniu
$filePath = './php-logo.png';
$fname = 'php-logo.png';
list($ret, $err) = $uploadMgr->putFile($token, $fname, $filePath);
echo "\n====> putFile result: \n";
if ($err !== null) {
    var_dump($err);
} else {
    var_dump($ret);
}</code>

?>

多高大上,白富美哈!!

题主显然工作量不饱和呀。

关键是你要问的问题是什么呢?segmentfault是个问答平台,你这个意见你应该去七牛的github项目上提issue或者上v2ex上发帖子吧?

七牛的赶紧把楼主请去当CTO,不然?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn