Example #1
0
 public function uploadVideo($file, $id)
 {
     if (empty($file)) {
         $this->setError(ErrorConf::topicContentImageEmpty());
         return false;
     }
     $obj = new alioss_sdk();
     $obj->set_debug_mode(FALSE);
     $bucket = $this->OSS_BUCKET_VIDEO;
     $tmpFile = $file['tmp_name'];
     $getID3 = new getID3();
     $id3Info = $getID3->analyze($tmpFile);
     $ext = $id3Info['fileformat'];
     if (!in_array($ext, $this->OSS_VIDEO_ENABLE)) {
         $this->setError(ErrorConf::topicContentVideoInvalidateType());
     }
     $times = ceil(@$id3Info['playtime_seconds'] + 0);
     $width = @$id3Info['video']['resolution_x'] + 0;
     $height = @$id3Info['video']['resolution_y'] + 0;
     $size = @$id3Info['filesize'];
     $from = $this->LOCAL_TMP_PATH . $id . rand(1, 100) . '.' . $ext;
     move_uploaded_file($tmpFile, $from);
     $to = $this->formatVideoFile($id, $ext);
     $responseObj = $obj->upload_file_by_file($bucket, $to, $from);
     if ($responseObj->status == 200) {
         $return['videopath'] = $to;
         $return['width'] = $width;
         $return['height'] = $height;
         $return['size'] = $size;
         $return['times'] = $times;
         return $return;
     } else {
         $this->setError(ErrorConf::topicContentImageEmpty());
         return false;
     }
 }
Example #2
0
 public function setAvatar($avatarfile, $uid)
 {
     if (!is_file($avatarfile)) {
         $this->setError(ErrorConf::noUploadAvatarfile());
         return false;
     }
     $obj = new alioss_sdk();
     //$obj->set_debug_mode(FALSE);
     $bucket = 'tutuavatar';
     $responseObj = $obj->upload_file_by_file($bucket, $uid, $avatarfile);
     if ($responseObj->status != 200) {
         $this->setError(ErrorConf::uploadAvatarfileFail());
     }
     $avatartime = time();
     $this->setUserinfo($uid, array('avatartime' => $avatartime));
     $this->clearUserCache($uid);
     // 		用户头像审核队列
     QueueManager::pushUserAvatarAudit($uid);
     QueueManager::pushUserToUpdateUserSysFriendLog($uid);
     return $avatartime;
 }