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 🙏

© 2024 – Pkg Stats / Ryan Hefner

wechat-media

v1.0.4

Published

manage wechat-enterprise media

Downloads

3

Readme

注意: 该npm包需要依赖node后台模板中的 ../libs/utils.js 和 ../config.dev/serverConfig.json

Download resource

var Wechat_media = require('wechat_media');
var company_id = "561f72fbe419be013b8b4zyx";
var option = {
	url: media_url,					//需要下载的资源url
	name: filename,					//要存储在本地的文件名
	type: media_type,				//文件类型,可以是"voice"或"image"
	savePath: savePath				//文件存储的相对路径
	};

Wechat_media.download(company_id, option).then(function(ret){
	if(ret.result){
		var save_url = ret.data.media_url; 			//下载后的媒体文件可以访问的url地址,你必须首先在serverConfig中设置 static_url,这个将会是 static_url+option.name
		var	type = ret.data.type;					//type为"voice"或"image"
		var file = ret.data.file;					//本地存储的文件地址
	}else{
		throw new Error("下载文件时出错");
	}
}).catch(function(e){
	console.log(e||e.stack);
})

Upload resource to Wechat

var Wechat_media = require('wechat_media');
var company_id = "561f72fbe419be013b8b4zyx";
var option = {
	media_url: media_url,		//非必须参数,由download方法返回
	file: filepath,				//本地存储文件的地址
	type: media_type			//可以是"type"或"image"
	};
Wechat_media.upload(company_id, option).then(function(ret){
	if(ret.result){
		var media_id = ret.data.media_id,			//上传到微信后返回的media_id
	}else{
		throw new Error("上传文件时出错");
		}
	}).catch(function(e){
		console.log(e||e.stack);
	})

Save resource from Wechat

var Wechat_media = require('wechat_media');
var company_id = "561f72fbe419be013b8b4zyx";
var option = {
	media_id: media_id,				//要从微信获取的素材的media_id
	name: filename,					//要存储在本地的文件名
	type: media_type,				//文件类型,可以是"voice"或"image"
	savePath: savePath				//文件存储的相对路径
};

Wechat_media.saveMedia(company_id, option).then(function(ret){
	if(ret.result){
		var media_url = ret.data.media_url;			//下载后的媒体文件可以访问的url地址,你必须首先在serverConfig中设置 static_url,这个将会是 static_url+option.name
		var	type = ret.data.type;					//type为"voice"或"image"
		var file = ret.data.file;					//本地存储的文件地址
	}else{
		throw new Error("下载文件时出错");
		}
}).catch(function(e){
	console.log(e||e.stack);
})

Installation

$ npm install wechat-media