import Crypto from '@/common/crypto/crypto.js';
import '@/common/crypto/hmac.js';
import '@/common/crypto/sha1.js';
import { Base64 } from '@/common/crypto/base64.js';

let date = new Date()
date = date.setHours(date.getHours() + 1)
let extime = "" + new Date(date).toISOString()
let policyText = {
  "expiration": extime,
  "conditions": [
    ["content-length-range", 0, 1024 * 1024 * 100] // 设置上传文件的大小限制 
  ]
};
let config = {
  accessid: 'LTAI5t6AWMP2imYzXGY43PzJ',
  accesskey: 'qNdgXZTle1ohzm5di0fzhiMMuy9P3T',
  osshost: 'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/other/',
  policyBase64: Base64.encode(JSON.stringify(policyText))
}
let message = config.policyBase64;
let bytes = Crypto.HMAC(Crypto.SHA1, message, config.accesskey, {
  asBytes: true
});
let signature = Crypto.util.bytesToBase64(bytes);
let timetamp = new Date().getTime();
let OSSConfig = {
  name: 'aliyun',
  host: config.osshost,
  accessid: config.accessid,
  signature: signature,
  policyBase64: config.policyBase64,
}
export default OSSConfig;