How to use cos-js-sdk-v5 - 2 common examples

To help you get started, we’ve selected a few cos-js-sdk-v5 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lanzhsh / react-vue-koa / vue-demo / src / utils / fileUpdate.js View on Github external
return new Promise((resolve, reject) => {
    const cos = new COS({
      getAuthorization: function(options, callback) {
        console.log(`options值为${JSON.stringify(options)}`)
        // 异步获取签名
        get(
            `https://download.aijiatui.com/api/Auth/signature?method=${options.Method ||
              'GET'}&pathname=${'/' + (options.Key || '')}`, {}, {
                withToken: false,
                ignoreCode: true
              }
          )
          .then(res => {
            const data = res.data
            callback(data.signature)
          })
          .catch(err=>{
            console.log(`err值为${JSON.stringify(err)}`)
github greper / d2-crud-plus / packages / d2-crud-plus-extends / src / file-uploder / lib / uploader / cos.js View on Github external
import config from '../config'
// 初始化实例
import COS from 'cos-js-sdk-v5'

let cos = null
if (config.cos.secretId != null && config.cos.secretId !== '' && config.cos.secretKey != null && config.cos.secretKey !== '') {
  cos = new COS({
    SecretId: config.cos.secretId,
    SecretKey: config.cos.secretKey
  })
} else {
  cos = new COS({
    // 必选参数
    getAuthorization (options, callback) { // 不传secretKey代表使用临时签名模式,此时此参数必传(安全,生产环境推荐)
      config.cos.getAuthorization(options).then(data => {
        // eslint-disable-next-line standard/no-callback-literal
        callback(data)
      })
    }
  })
}

export default {
  /**
   *
   * @param parent
   * @param file
   * @param custom

cos-js-sdk-v5

JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)

MIT
Latest version published 4 days ago

Package Health Score

76 / 100
Full package analysis

Popular cos-js-sdk-v5 functions

Similar packages