Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
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
方斌
51business
Commits
a51c67d4
Commit
a51c67d4
authored
Apr 18, 2019
by
方斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
signature
parent
8757be10
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
0 deletions
+88
-0
oss.js
app/controller/common/oss.js
+11
-0
router.js
app/router.js
+2
-0
common.js
app/router/common.js
+7
-0
oss.js
app/service/common/oss.js
+68
-0
No files found.
app/controller/common/oss.js
0 → 100644
View file @
a51c67d4
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
CommonController
extends
Controller
{
async
signature
()
{
const
{
service
,
ctx
}
=
this
;
const
ret
=
await
service
.
common
.
oss
.
get_business_signature
();
ctx
.
success
(
ret
);
}
}
module
.
exports
=
CommonController
;
app/router.js
View file @
a51c67d4
...
...
@@ -11,4 +11,6 @@ module.exports = app => {
require
(
'./router/gjj'
)(
app
);
require
(
'./router/official'
)(
app
);
// 官网招聘和投资者关系
require
(
'./router/common'
)(
app
);
// 存储公共的东西,比如 cdn , oss, 白名单等等
};
app/router/common.js
0 → 100644
View file @
a51c67d4
'use strict'
;
module
.
exports
=
app
=>
{
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
+
'/common'
);
router
.
get
(
'third_oss_signature'
,
'/oss/signature'
,
'common.oss.signature'
);
// 业务的 oss 签名
};
app/service/common/oss.js
0 → 100644
View file @
a51c67d4
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
class
CommonService
extends
Service
{
// 获取51shequ的oss签名
async
get_business_signature
()
{
const
{
ctx
}
=
this
;
const
region
=
'oss-cn-hangzhou'
;
const
bucket
=
'51shequ'
;
const
id
=
'LTAIbdayv82O7OYM'
;
const
key
=
'plCSzfiZCpMoh39omrzdaHHEltv4Un'
;
const
host
=
'//'
+
bucket
+
'.'
+
region
+
'.aliyuncs.com'
;
const
url
=
"//r.51gjj.com/"
;
let
now
=
Math
.
round
(
new
Date
().
getTime
()
/
1000
).
toString
();
const
expire
=
120
;
let
end
=
now
+
expire
;
let
expiration
=
new
Date
().
toISOString
().
replace
(
/
\.
.+/
,
''
)
+
'Z'
;
let
dir
=
'webpublic/resume/'
;
//最大文件大小.用户可以自己设置
let
condition
=
new
Array
(
3
);
condition
[
0
]
=
'content-length-range'
;
condition
[
1
]
=
0
;
condition
[
2
]
=
1048576000
;
let
start
=
new
Array
(
'starts-with'
,
'$key'
,
dir
);
let
conditions
=
new
Array
(
condition
,
start
);
let
policy
=
{
expiration
:
expiration
,
conditions
:
conditions
};
let
base64_policy
=
new
Buffer
(
JSON
.
stringify
(
policy
)).
toString
(
'base64'
);
let
string_to_sign
=
base64_policy
;
const
crypto
=
require
(
'crypto'
);
let
signature
=
crypto
.
createHash
(
'sha1'
).
update
(
string_to_sign
).
digest
().
toString
(
'base64'
);;
let
config
=
{
region
,
accessKeyId
:
id
,
accessKeySecret
:
key
,
bucket
:
bucket
,
}
let
response
=
{
accessid
:
id
,
static_host
:
url
+
dir
,
host
:
host
,
policy
:
base64_policy
,
signature
:
signature
,
expire
:
end
,
config
:
config
,
dir
};
return
response
;
}
}
module
.
exports
=
CommonService
;
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