game2005api/webapp/controller/VoiceController.class.php
aozhiwei 6fdbebd2fd 1
2021-11-23 14:31:17 +08:00

34 lines
1006 B
PHP

<?php
class VoiceController extends BaseAuthedController {
public function upload()
{
$raw_data = file_get_contents('php://input');
$data = base64_encode($raw_data);
$md5 = md5($data);
$r = $this->getRedis($md5);
$r->set('game2005:voice:' . $md5, $data);
$r -> pexpire('game2005:voice:' . $md5, 1000 * 600);
$url = '';
if (SERVER_ENV == _ONLINE) {
$url = "https://game2005api.kingsome.cn/webapp/index.php?c=Voice&a=download&res_id=" . $md5;
} else {
$url = "https://game2005api-test.kingsome.cn/webapp/index.php?c=Voice&a=download&res_id=" . $md5;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'download_url' => $url
));
}
public function download()
{
$r = $this->getRedis($_REQUEST['res_id']);
$data = $r->get('game2005:voice:' . $_REQUEST['res_id']);
echo base64_decode($data);
}
}