🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@cloudbase/extension-ci-wxmp

Package Overview
Dependencies
Maintainers
11
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudbase/extension-ci-wxmp

latest
npmnpm
Version
0.1.2
Version published
Weekly downloads
44
2100%
Maintainers
11
Weekly downloads
 
Created
Source

数据万象Cloud Infinite(扩展)

Usage

请先到腾讯云控制台上开通对应的数据万象扩展

const extCi = require('@cloudbase/extension-ci-wxmp')

const res = await extCi.invoke(opts)

opts包含以下属性

名称类型是否必须说明
actionstring操作类型
cloudPathstring文件的绝对路径,与tcb.uploadFile中一致,除盲水印功能外,其它功能必须存在此路径的文件
fileContentUint8Array|Buffer|ArrayBuffer文件内容, 盲水印选传
operationsobject数据万象的headers中的Pic-Operations字段,图像处理或者盲水印功能时需要填入的参数

action目前包含以下类型

  • DetectLabel
  • DetectType
  • WaterMark
  • ImageProcess

fileContent在小程序中的获取方式参考

const readFile = async function() {
    let res = await new Promise(resolve=>{
        wx.chooseImage({
            success: function(res) {
                let filePath = res.tempFilePaths[0]
                let fm = wx.getFileSystemManager()
                fm.readFile({
                    filePath,
                    success(res){
                        resolve(res)
                    }
                })
            }    
        })
    })
    return res
}
let fileContent = await readFile()

功能说明

图像处理

参考文档万象文档 云上数据处理

const ops = {
    rules:[{
        rule:'QRcode/cover/0'
    }]
}

const res = await extCi.invoke({
    cloudPath: "bb.png",
    action:'ImageProcess',
    operations:ops
})

console.log(JSON.stringify(res,null,4))
}

盲水印

参考文档万象文档 盲水印功能

const ops = {
    rules:[{
        fileid:'qr6.jpg'
        rule:{
            mode:3,
            type:3,
            text:'1234'
        }
    }]
}

const res = await extCi.invoke({
    action:'WaterMark',
    cloudPath: "qr5.jpg",
    fileContent //非必须
    operations:ops
})

图片标签

参考文档万象文档 图片标签

const res = await extCi.invoke({
    action:'DetectLabel',
    cloudPath: "ab.png"
})

console.log(JSON.stringify(res,null,4))

安全审核

参考文档万象文档 内容识别


const opts = {
    type: "porn" // 审核类型:porn(涉黄识别)、terrorist(涉暴恐识别)、politics(涉政识别)、ads(广告识别),可选择多种识别类型,如porn,ads
}
const res = await extCi.invoke({
    action:'DetectType',
    operations:opts,
    cloudPath: "ab.png"
})

console.log(JSON.stringify(res,null,4))

FAQs

Package last updated on 24 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts