How to use cos-nodejs-sdk-v5 - 8 common examples

To help you get started, we’ve selected a few cos-nodejs-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 vitarn / serverless-qcloud-scf / provider.ts View on Github external
constructor(serverless, options = {}) {
        super(serverless, options)

        this.naming = Object.assign({ provider: this }, naming)
        this.options = options
        this.provider = this // only load plugin in a Qcloud service context
        this.serverless = serverless
        this.serverless.setProvider(naming.providerName, this)

        this.sdk = {
            scf: BbPromise.promisifyAll(this.getQcloudAPI({ serviceType: 'scf' })),
            apigateway: new QcloudAPIGateway(this.qcloudOptions),
            cos: BbPromise.promisifyAll(new QcloudCOS(this.qcloudOptions)),
            cls: BbPromise.promisifyAll(this.getQcloudAPI({ serviceType: 'cls' })),

            /**
             * the following is just a dummy assignment and should be updated once the official API is available
             * @see https://cloud.tencent.com/product/coc
             */
            coc: null,
        }

        this.cli = {
            warn(message) {
                serverless.cli.consoleLog(`Serverless: ${chalk.yellowBright(`[WARN] ${message}`)}`)
            },

            error(message) {
                serverless.cli.consoleLog(`Serverless: ${chalk.redBright(`[ERROR] ${message}`)}`)
github willnewii / qiniuClient / src / renderer / cos / tencent.js View on Github external
function init(param) {
    cos = new tencent({
        SecretId: param.access_key,
        SecretKey: param.secret_key,
    });
}
github TencentCloudBase / cloudbase-manager-node / src / env / index.ts View on Github external
private getCos() {
        const { secretId, secretKey, token } = this.getAuthConfig()
        if (!token) {
            return new COS({
                SecretId: secretId,
                SecretKey: secretKey
            })
        }

        return new COS({
            getAuthorization: function(_, callback) {
                callback({
                    TmpSecretId: secretId,
                    TmpSecretKey: secretKey,
                    XCosSecurityToken: token,
                    ExpiredTime: 3600 * 1000
                })
            }
        })
    }
github TencentCloudBase / cloudbase-manager-node / src / storage / index.ts View on Github external
private getCos() {
        const { secretId, secretKey, token, proxy } = this.getAuthConfig()
        const cosProxy = process.env.TCB_COS_PROXY
        if (!token) {
            return new COS({
                SecretId: secretId,
                SecretKey: secretKey,
                Proxy: cosProxy || proxy
            })
        }

        return new COS({
            getAuthorization: function(_, callback) {
                callback({
                    TmpSecretId: secretId,
                    TmpSecretKey: secretKey,
                    XCosSecurityToken: token,
                    ExpiredTime: 3600 * 1000,
                    Proxy: cosProxy || proxy
                })
            }
github TencentCloudBase / cloudbase-manager-node / src / env / index.ts View on Github external
private getCos() {
        const { secretId, secretKey, token } = this.getAuthConfig()
        if (!token) {
            return new COS({
                SecretId: secretId,
                SecretKey: secretKey
            })
        }

        return new COS({
            getAuthorization: function(_, callback) {
                callback({
                    TmpSecretId: secretId,
                    TmpSecretKey: secretKey,
                    XCosSecurityToken: token,
                    ExpiredTime: 3600 * 1000
                })
            }
        })
    }
github tencentyun / scf-demo-repo / Node8.9_CosUnzipFile / common / utils.js View on Github external
function initCosInstance({ SecretId, SecretKey, XCosSecurityToken, ...args }) {
  const cosInstance = new COS({
    SecretId,
    SecretKey,
    XCosSecurityToken,
    ...args
  })

  const keys = Object.keys(COS.prototype)
  const noRetryKeys = ['getObject', 'putObject']

  appendFunction({
    target: cosInstance,
    keys: noRetryKeys,
    maxTryTime: 1
  })

  appendFunction({
    target: cosInstance,
    keys: keys.filter(key => !noRetryKeys.includes(key)),
    maxTryTime: 3
  })
  return cosInstance
}
github CFETeam / weapp-demo-album / server / services / cos / index.js View on Github external
const COS = require('cos-nodejs-sdk-v5')
const _cosConfig = require('cos-nodejs-sdk-v5/sdk/config')
const config = require('../../config')

/**
 * init COS config
 * see: https://github.com/tencentyun/cos-nodejs-sdk-v5/blob/master/sdk/config.js#L24
 */
_cosConfig.setAppInfo(config.cosAppId, config.cosSecretId, config.cosSecretKey);

module.exports = COS
github willnewii / qiniuClient / src / renderer / cos / tencent.js View on Github external
import cosUtil from 'cos-nodejs-sdk-v5/sdk/util';

cosUtil.isBrowser = false;
import tencent from 'cos-nodejs-sdk-v5';

import TencentBucket from "@/cos/tencentBucket";
import qiniu from "qiniu";

let cos = null;

//独立于各COS的配置
const PROTOCOL = 'http://';

const methods = {
    //空间对应的域名列表(授权空间域名返回为空)
    domains: 'https://api.qiniu.com/v6/domain/list',
    //获取目录(是通过公共前缀模拟出的效果)
    resources: 'https://rsf.qbox.me/list',
};

cos-nodejs-sdk-v5

cos nodejs sdk v5

MIT
Latest version published 4 months ago

Package Health Score

70 / 100
Full package analysis