Skip to content

Commit

Permalink
chore: 生成token 显示过期时间
Browse files Browse the repository at this point in the history
  • Loading branch information
ATQQ committed Apr 23, 2024
1 parent 040e877 commit 238fde4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/cli/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const options = {
const putPolicy = new qiniu.rs.PutPolicy(options)
const uploadToken = putPolicy.uploadToken(mac)

console.log('expire', new Date(Date.now() + options.expires * 1000).toLocaleString())

const envToken = btoa(JSON.stringify({
token: uploadToken,
date: Date.now() + options.expires * 1000,
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/upyun-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const prefix = process.env.UPYUN_PREFIX
const scope = process.env.UPYUN_SCOPE
const method = 'PUT'
const uriPrefix = `/${bucket}/${prefix}/${scope}`
const expire = new Date().getTime() + (+process.env.UPYUN_EXPIRES) || 1000 * 60 * 60 * 24 * 90 // 90天的过期时间
const expire = new Date().getTime() + (+process.env.UPYUN_EXPIRES * 1000) || 1000 * 60 * 60 * 24 * 90 // 90天的过期时间
console.log('expire', new Date(expire).toLocaleString())
const domain = process.env.UPYUN_DOMAIN

const envToken = btoa(JSON.stringify({
Expand Down

0 comments on commit 238fde4

Please sign in to comment.