npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cos-wx-sdk-v5u3

v1.7.3

Published

基于小程序 SDK for [腾讯云对象存储服务](https://cloud.tencent.com/product/cos)修改的ES6 Module

Readme

腾讯云对象存储服务(ES6 Module)

基于小程序 SDK for 腾讯云对象存储服务修改的ES6 Module

因项目采用了vue3不支持小程序amd方式,修改为es6 module , 为了进一步支持ts已添加声明文件.d.ts

示例

放个示例方便大家使用,另外附上官网链接腾讯云对象存储服务

使用(建议npm)

npm i cos-wx-sdk-v5u3

vue3

<template>
	<view class="content">
		<view class="text-area">
			ES6 Module
		</view>
	</view>
</template>

<script setup>
	
	// 引入腾讯云对象存储 SDK - 修改的版本是V5基于VUE3 ; 如果是导入本地插件需要选择正确路径
	import COS from 'cos-wx-sdk-v5u3';
	
	// 初始化
	const cos = new COS({
		// getAuthorization: funciton() {}, // 参考上方初始化
		SecretId: 'xx', // sts 服务下发的临时 secretId
		SecretKey: 'xx', // sts 服务下发的临时 secretKey
		SimpleUploadMethod: 'putObject', // 强烈建议,高级上传、批量上传内部对小文件做简单上传时使用putObject
	});

	function handleFileInUploading(fileName, filePath) {
		cos.uploadFile({
			Bucket: 'ljx-1301875625',
			/* 填写自己的 bucket,必须字段 */
			Region: 'ap-shanghai',
			/* 存储桶所在地域,必须字段 */
			Key: fileName,
			/* 存储在桶里的对象键(例如:1.jpg,a/b/test.txt,图片.jpg)支持中文,必须字段 */
			FilePath: filePath,
			/* 上传文件路径,必须字段 */
			SliceSize: 1024 * 1024 * 5,
			/* 触发分块上传的阈值,超过5MB使用分块上传,小于5MB使用简单上传。可自行设置,非必须 */
			onProgress: function(progressData) {
				console.log(JSON.stringify(progressData));
			}
		}, function(err, data) {
			if (err) {
				console.log('上传失败', err);
			} else {
				console.log('上传成功', data);
			}
		});
	}

	/* 选择文件,得到临时路径(以选择图片为例,选择其他文件请参考小程序官方 api) */
	wx.chooseImage({
		count: 1, // 默认9
		sizeType: ['original'], // 可以指定是原图还是压缩图,默认用原图
		sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
		success: function(res) {
			const filePath = res.tempFiles[0].path;
			const fileName = filePath.substr(filePath.lastIndexOf('/') + 1);
			handleFileInUploading(fileName, filePath);
		}
	});
</script>

<style>

</style>

vue2

<template>
 <view class="content">
  <view class="text-area" @click="handleChooseImage">
   ES6 Module
  </view>
 </view>
</template>

<script>
 export default {
  data() {
   return {
	cos: null
   }
  },
  mounted() {
   // 引入腾讯云对象存储 SDK - 修改的版本是V5基于VUE3 ; 如果是导入本地插件需要选择正确路径
   this.cos = new COS({
	// getAuthorization: funciton() {}, // 参考上方初始化
	SecretId: 'xx', // sts 服务下发的临时 secretId
	SecretKey: 'xx', // sts 服务下发的临时 secretKey
	SimpleUploadMethod: 'putObject', // 强烈建议,高级上传、批量上传内部对小文件做简单上传时使用putObject
   });
  },
  methods: {
   /* 选择文件,得到临时路径(以选择图片为例,选择其他文件请参考小程序官方 api) */
   handleChooseImage() {
	 wx.chooseImage({
	  count: 1, // 默认9
	  sizeType: ['original'], // 可以指定是原图还是压缩图,默认用原图
	  sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
	  success: function(res) {
	   const filePath = res.tempFiles[0].path;
	   const fileName = filePath.substr(filePath.lastIndexOf('/') + 1);
	   handleFileInUploading(fileName, filePath);
	  }
	 });
   },
   handleFileInUploading(fileName, filePath) {
	this.cos.uploadFile({
	 Bucket: 'ljx-1301875625',
	 /* 填写自己的 bucket,必须字段 */
	 Region: 'ap-shanghai',
	 /* 存储桶所在地域,必须字段 */
	 Key: fileName,
	 /* 存储在桶里的对象键(例如:1.jpg,a/b/test.txt,图片.jpg)支持中文,必须字段 */
	 FilePath: filePath,
	 /* 上传文件路径,必须字段 */
	 SliceSize: 1024 * 1024 * 5,
	 /* 触发分块上传的阈值,超过5MB使用分块上传,小于5MB使用简单上传。可自行设置,非必须 */
	 onProgress: function(progressData) {
	  console.log(JSON.stringify(progressData));
	 }
	}, function(err, data) {
	 if (err) {
	  console.log('上传失败', err);
	 } else {
	  console.log('上传成功', data);
	 }
	});
   }
  }
 }
</script>