时间:2021-07-01 10:21:17 帮助过:30人阅读
请问这是为什么啊?!! 测试文件如下,本地localhost测试:
require_once("qiniu/io.php");
require_once("qiniu/rs.php");
$bucket = "qicheshipin";
$key1 = "950.jpg";
$accessKey = '我的key';
$secretKey = '我的key';
Qiniu_SetKeys($accessKey, $secretKey);
$putPolicy = new Qiniu_RS_PutPolicy($bucket);
$upToken = $putPolicy->Token(null);
$putExtra = new Qiniu_PutExtra();
$putExtra->Crc32 = 1;
list($ret, $err) = Qiniu_PutFile($upToken, $key1, __file__, $putExtra);
echo "====> Qiniu_PutFile result: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}
返回数据:
Qiniu_PutFile result: array(2) { ["hash"]=> string(28) "Fk4xlsc7g7urp1VfwkBZv7UCjyqC" ["key"]=> string(7) "950.jpg" }
七牛反馈显示信息说明已经成功了,但是在七牛空间显示的文件却不完整
请问这是为什么啊?!! 测试文件如下,本地localhost测试:
require_once("qiniu/io.php");
require_once("qiniu/rs.php");
$bucket = "qicheshipin";
$key1 = "950.jpg";
$accessKey = '我的key';
$secretKey = '我的key';
Qiniu_SetKeys($accessKey, $secretKey);
$putPolicy = new Qiniu_RS_PutPolicy($bucket);
$upToken = $putPolicy->Token(null);
$putExtra = new Qiniu_PutExtra();
$putExtra->Crc32 = 1;
list($ret, $err) = Qiniu_PutFile($upToken, $key1, __file__, $putExtra);
echo "====> Qiniu_PutFile result: \n";
if ($err !== null) {
var_dump($err);
} else {
var_dump($ret);
}
返回数据:
Qiniu_PutFile result: array(2) { ["hash"]=> string(28) "Fk4xlsc7g7urp1VfwkBZv7UCjyqC" ["key"]=> string(7) "950.jpg" }
上面的结果应该是证明文件已经传成功了。"在七牛空间显示的文件却不完整" 是指什么?通过 http://qicheshipin.u.qiniudn.com/950.jpg 可以访问到这个文件么?另外,在上传成功后有没有做过其他事情,比如 delete 这个文件?
搞定了,Qiniu_PutFile函数第三个参数默认使用file,修改为上传文件本地绝对路径后成功!
求大神帮忙
http://segmentfault.com/q/1010000000343075#a-1020000000345187