mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2026-02-18 10:13:49 +00:00
oss 上传新增host 配置, 支持配置cdn
This commit is contained in:
parent
63b290ba9f
commit
c1d54feae0
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/core",
|
"name": "@cool-midway/core",
|
||||||
"version": "6.0.4",
|
"version": "6.0.5",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "index.d.ts",
|
"typings": "index.d.ts",
|
||||||
|
|||||||
@ -147,6 +147,8 @@ export interface OSSConfig {
|
|||||||
expAfter?: number;
|
expAfter?: number;
|
||||||
/** 文件最大的 size */
|
/** 文件最大的 size */
|
||||||
maxSize?: number;
|
maxSize?: number;
|
||||||
|
// host
|
||||||
|
host?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/core",
|
"name": "@cool-midway/core",
|
||||||
"version": "6.0.4",
|
"version": "6.0.5",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"typings": "index.d.ts",
|
"typings": "index.d.ts",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/file",
|
"name": "@cool-midway/file",
|
||||||
"version": "6.0.1",
|
"version": "6.0.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "index.d.ts",
|
"typings": "index.d.ts",
|
||||||
|
|||||||
@ -308,6 +308,7 @@ export class CoolFile {
|
|||||||
endpoint,
|
endpoint,
|
||||||
expAfter = 300000,
|
expAfter = 300000,
|
||||||
maxSize = 200 * 1024 * 1024,
|
maxSize = 200 * 1024 * 1024,
|
||||||
|
host,
|
||||||
} = this.config.oss;
|
} = this.config.oss;
|
||||||
const oss = {
|
const oss = {
|
||||||
bucket,
|
bucket,
|
||||||
@ -317,7 +318,7 @@ export class CoolFile {
|
|||||||
expAfter, // 签名失效时间,毫秒
|
expAfter, // 签名失效时间,毫秒
|
||||||
maxSize, // 文件最大的 size
|
maxSize, // 文件最大的 size
|
||||||
};
|
};
|
||||||
const host = `https://${bucket}.${endpoint}`;
|
const newHost = host ? host : `https://${bucket}.${endpoint}`;
|
||||||
const expireTime = new Date().getTime() + oss.expAfter;
|
const expireTime = new Date().getTime() + oss.expAfter;
|
||||||
const expiration = new Date(expireTime).toISOString();
|
const expiration = new Date(expireTime).toISOString();
|
||||||
const policyString = JSON.stringify({
|
const policyString = JSON.stringify({
|
||||||
@ -336,7 +337,7 @@ export class CoolFile {
|
|||||||
return {
|
return {
|
||||||
signature,
|
signature,
|
||||||
policy,
|
policy,
|
||||||
host,
|
host: newHost,
|
||||||
OSSAccessKeyId: accessKeyId,
|
OSSAccessKeyId: accessKeyId,
|
||||||
success_action_status: 200,
|
success_action_status: 200,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -61,6 +61,8 @@ export interface OSSConfig {
|
|||||||
expAfter?: number;
|
expAfter?: number;
|
||||||
// 文件最大的 size
|
// 文件最大的 size
|
||||||
maxSize?: number;
|
maxSize?: number;
|
||||||
|
// host
|
||||||
|
host?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cool-midway/file",
|
"name": "@cool-midway/file",
|
||||||
"version": "6.0.1",
|
"version": "6.0.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"typings": "index.d.ts",
|
"typings": "index.d.ts",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user