Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
media-resource
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨昕
media-resource
Commits
6bfb8608
Commit
6bfb8608
authored
Sep 06, 2022
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加获取百度oss口令
parent
5577ee96
Pipeline
#19420
passed with stages
in 1 minute 4 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
MediaController.php
app/Http/Controllers/Api/Client/MediaController.php
+5
-0
BaiduOssModel.php
app/Model/BaiduOssModel.php
+37
-0
No files found.
app/Http/Controllers/Api/Client/MediaController.php
View file @
6bfb8608
...
...
@@ -2,6 +2,7 @@
namespace
App\Http\Controllers\Api\Client
;
use
App\Model\AliOssModel
;
use
App\Model\BaiduOssModel
;
use
Illuminate\Validation\Rule
;
use
App\Exceptions\FormException
;
use
App\Model\MediaModel
;
...
...
@@ -28,6 +29,7 @@ class MediaController extends Controller
const
OSS_ALI
=
'ALI'
;
const
OSS_QI_QIU
=
'QI_NIU'
;
const
OSS_BAIDU
=
'BAIDU'
;
/**
* 获取媒资ID
...
...
@@ -84,6 +86,9 @@ class MediaController extends Controller
$domain
=
$this
->
domain
[
$branch
];
$data
=
[
"token"
=>
$token
,
'domain'
=>
$domain
];
break
;
case
self
::
OSS_BAIDU
:
$data
=
BaiduOssModel
::
getBaiduOssToken
(
$request
);
break
;
default
:
$token
=
QiniuModel
::
uploadToken
(
$this
->
bucketList
[
$branch
],
$key
);
$domain
=
$this
->
domain
[
$branch
];
...
...
app/Model/BaiduOssModel.php
0 → 100644
View file @
6bfb8608
<?php
namespace
App\Model
;
class
BaiduOssModel
{
/**
* @param $request
* @return mixed
*/
public
static
function
getBaiduOssToken
(
$request
){
try
{
$ali_base_url
=
getenv
(
'ofc-store-svr'
)
?
getenv
(
'ofc-store-svr'
)
:
"http://ofc-store-svr-svr.micro"
;
$url
=
$ali_base_url
.
"/api/v1/bdAssumeRole"
;
$data
=
array
(
"body"
=>
'{"accessControlList":[{"service":"bce:bos","region":"bj","effect":"Allow","resource":["media-test-bce/*"],"permission":["READ","WRITE"]}]}'
);
$header
=
array
(
'Content-Type: application/json; charset=utf-8'
,
'Content-Length: '
.
strlen
(
json_encode
(
$data
))
);
$res
=
http_request_code
(
$url
,
$header
,
"POST"
,
json_encode
(
$data
),
2
);
LogModel
::
addlog
([
" 获取百度OSS临时token 1"
=>
$res
,
"请求URL"
=>
$url
,
"请求头header"
=>
$header
]);
$result
=
json_decode
(
$res
,
true
);
if
(
$result
[
"code"
]
!=
0
){
throw
new
\Exception
(
"获取token失败"
);
}
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$result
[
"data"
];
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment