-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support PostObject policy v4 signature and restore archive obje…
…ct set days (#1340) Co-authored-by: zhengzuoyu.zzy <[email protected]>
- Loading branch information
Showing
17 changed files
with
539 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export declare function signPostObjectPolicyV4(this: any, policy: string | object, date: Date): string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
const __importDefault = | ||
(this && this.__importDefault) || | ||
function (mod) { | ||
return mod && mod.__esModule ? mod : { default: mod }; | ||
}; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.signPostObjectPolicyV4 = void 0; | ||
const dateformat_1 = __importDefault(require('dateformat')); | ||
const getStandardRegion_1 = require('../utils/getStandardRegion'); | ||
const policy2Str_1 = require('../utils/policy2Str'); | ||
const signUtils_1 = require('../signUtils'); | ||
|
||
function signPostObjectPolicyV4(policy, date) { | ||
const policyStr = Buffer.from(policy2Str_1.policy2Str(policy), 'utf8').toString('base64'); | ||
const formattedDate = dateformat_1.default(date, "UTC:yyyymmdd'T'HHMMss'Z'"); | ||
const onlyDate = formattedDate.split('T')[0]; | ||
const signature = signUtils_1.getSignatureV4( | ||
this.options.accessKeySecret, | ||
onlyDate, | ||
getStandardRegion_1.getStandardRegion(this.options.region), | ||
policyStr | ||
); | ||
return signature; | ||
} | ||
exports.signPostObjectPolicyV4 = signPostObjectPolicyV4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import dateFormat from 'dateformat'; | ||
|
||
import { getStandardRegion } from '../utils/getStandardRegion'; | ||
import { policy2Str } from '../utils/policy2Str'; | ||
import { getSignatureV4 } from '../signUtils'; | ||
|
||
export function signPostObjectPolicyV4(this: any, policy: string | object, date: Date): string { | ||
const policyStr = Buffer.from(policy2Str(policy), 'utf8').toString('base64'); | ||
const formattedDate = dateFormat(date, "UTC:yyyymmdd'T'HHMMss'Z'"); | ||
const onlyDate = formattedDate.split('T')[0]; | ||
|
||
const signature = getSignatureV4( | ||
this.options.accessKeySecret, | ||
onlyDate, | ||
getStandardRegion(this.options.region), | ||
policyStr | ||
); | ||
|
||
return signature; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.