搜索

首页  >  问答  >  正文

java - 七牛 取指定的空间下面的文件条目,报错

发现部分空间是可以
部分空间不可以,报下面的错误
{ResponseInfo:com.qiniu.http.Response@74d25d10,status:631, reqId:OUgAAEnJhJQ3MY4U, xlog:CFGG:3/612;ZONEPROXY:12/631, xvia:, adress:rsf.qbox.me/183.136.139.24:80, duration:0.000000 s, error:no such bucket}

PHPzPHPz2767 天前1136

全部回复(1)我来回复

  • 梦想无需昭告天下

    梦想无需昭告天下2017-09-26 23:14:44

    /**

    * 验证码类

    */

    $code= new Code();

    $code->outImage();

    class Code

    {

    protected $number;

    受保护的 $codeType;

    受​​保护的 $width;

    受​​保护的 $height;

    受​​保护的 $image;

    受​​保护的 $code;

    公共函数 __construct($number=4,$codeType=2,$width= 100,$height=30)

    {

    $this->number=$number;

    $this->codeType=$codeType;

    $this->width=$width;

    $this ->height=$height;

    $this->code=$this->createCode();

    }

    public function __get($name){

    if ($name=='code' ) {

    return $this->code;

    }else{

    return false;

    }

    }

    public function __destruct(){

    imagedestroy($this->image);

    }

    protected function createCode(){

    switch ($this->codeType) {

    case '0':

    $code=$this->getNumberCode();

    break;

    case ' 1':

    $code=$this->getCharCode();

    break;

    case '2':

    $code=$this->getNumberCharCode();

    break;

    默认值:

    die("对不起,不支持该验证码类型!!!");

    }

    return $code;

    }

    protected function getNumberCode(){

    $str=join('',range (0, 9));

    return substr(str_shuffle($str), 0,$this->number);

    }

    protected function getCharCode(){

    $str=join('',range (a, z));

    $str=$str.strtoupper($str);

    return substr(str_shuffle($str), 0,$this->number);

    }

    protected function getNumberCharCode (){

    $str1=join('',range(0, 9));

    $str=join('',range(a, z));

    $str=$str1.$str. strtoupper($str);

    return substr(str_shuffle($str), 0,$this->number);

    }

    public function outImage(){

    $this->createImage();

    $this->fillBack();

    $this->drawChar();

    $this->drawDistrub();

    $this->show();

    }

    受保护函数createImage(){

    $this->image=imagecreatetruecolor($this->width, $this->height);

    }

    protected function fillBack(){

    imagefill($this->图像, 0, 0, $this->lightColor());

    }

    受保护函数 lightColor(){

            return  imagecolorallocate($this->image, mt_rand(130,255), mt_rand(130,255), mt_rand (130,255));

    }

    protected function darkColor(){

    return  imagecolorallocate($this->image, mt_rand(0,120), mt_rand(0,120), mt_rand(0,120));

    }

    protected函数drawChar(){

    for ($i=0; $i <$this->数字; $i++) { 

    $Width=$this->width/$this->number;

    $x=mt_rand($i*$Width+10,($i+1)*$Width-15);

    $y=mt_rand(0,$this->height-18);

    imagechar( $this->image, 6, $x, $y, $this->code[$i], $this->darkColor());

    }

    }

    protected function drawDistrub(){

    for ($i=0; $i < 300; $i++) { 

    $x=mt_rand(0,$this->宽度);

    $y=mt_rand(0,$this->宽度);

    $y=mt_rand(0,$this->宽度) height);

    imagesetpixel($this->image, $x, $y, $this->lightColor());

    }

    }

    protected function show(){

    header("Content -类型:image/png");

    imagepng($this->image);

    }

    }

    ?>

    🎜🎜

    回复
    0
  • 取消回复