修改内容
This commit is contained in:
parent
e16ad5327f
commit
a3aa5ae691
@ -120,7 +120,7 @@ async function getSTSToken() {
|
||||
return result.json();
|
||||
}
|
||||
|
||||
const oss = new OSS({
|
||||
const client = new OSS({
|
||||
region: 'oss-cn-hangzhou', // 填入你的bucket所在的地域
|
||||
accessKeyId: result.accessKeyId, // 临时凭证的AccessKeyId
|
||||
accessKeySecret: result.accessKeySecret, // 临时凭证的AccessKeySecret
|
||||
@ -166,17 +166,17 @@ const client = new OSS({
|
||||
accessKeyId: 'yourAccessKeyId', // 填入你的AccessKeyId
|
||||
accessKeySecret: 'yourAccessKeySecret', // 填入你的AccessKeySecret
|
||||
bucket: 'mybucket', // 填入你的bucket名称
|
||||
endpoint: 'https://yourdomain.com' // 如果有自定义域名就填
|
||||
endpoint: 'https://yourdomain.com', // 如果有自定义域名就填
|
||||
cname: true, // 如果使用自定义域名,则需要设置为true
|
||||
secure: true, // 如果强制https,则需要设置为true
|
||||
authorizationV4: true, // 按阿里云官方文档,使用V4签名
|
||||
authorizationV4: true // 按阿里云官方文档,使用V4签名
|
||||
});
|
||||
|
||||
app.get('/get-url', async (req, res) => {
|
||||
// 完成用户权限验证,如通过token获取id
|
||||
const userId = req.user.id;
|
||||
|
||||
const { fileKey } = req.body;
|
||||
const { fileKey } = req.query;
|
||||
const url = await client.signatureUrlV4(
|
||||
'GET', // 设置请求方法
|
||||
20, // 设置签名URL的有效期,单位为秒
|
||||
@ -188,7 +188,7 @@ app.get('/get-url', async (req, res) => {
|
||||
// 设置请求参数
|
||||
'response-content-disposition': 'attachment' // 如果要强制浏览器下载,则需要设置此参数
|
||||
// 还可以自定义文件名
|
||||
// 'response-content-type': 'attachment; filename="example.file"'
|
||||
// 'response-content-disposition': 'attachment; filename="example.file"'
|
||||
}
|
||||
},
|
||||
fileKey // 填入文件路径
|
||||
|
Loading…
x
Reference in New Issue
Block a user