您现在的位置是:首页 >技术杂谈 >七牛云认证鉴黄并进行文件的上传网站首页技术杂谈
七牛云认证鉴黄并进行文件的上传
简介最近项目有用到七牛云存储,需要对上传的照片进行鉴黄并上传报存
vendor('Qiniu.autoload'); $auth=new Auth("七牛云AK","七牛云SK"); //进行认证 $url = "http://ai.qiniuapi.com/v3/image/censor"; $method = "POST"; $host = "ai.qiniuapi.com"; $body = "{"data":{"uri":"图片路径"},"params":{"scenes":["pulp"]}}"; $contentType = "application/json"; $headers = $auth->authorizationV2($url,$method,$body,$contentType); $headers['Content-Type'] = $contentType; $headers['Host'] = $host; $response=Client::post($url,$body,$headers); if($response->ok()){ $res = $response->json(); $sugges =$ res['result']['suggestion'];//七牛云状态block/review/pass-违规/涉嫌/正常 $policy = array('callbackUrl'=>'','callbackBody'=>''); $token = $auth->uploadToken("七牛云空间",null,3600,$policy); //初始化UploadManager对象并进行文件的上传 $uploadMgr = new UploadManager(); //调用UploadManager的putFile方法进行文件的上传 $uploadMgr->putFile($token,"图片路径","本地图片路径"); }
梦想加空间!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。