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

s94-file

v1.1.3

Published

浏览器中,用于文件上传和在线文件选择的可视化插件

Downloads

4

Readme

s94-file

浏览器中,用于文件上传和在线文件选择的可视化插件

安装

$ npm install s94-file

使用

var file = require('s94-file');
$('.btn').on('click',function(){
	//调起插件界面
	file({
		upload_url: '后台上传接口',
		filelist_url: '后台文件列表接口',
		max_file: 10,
		max_size: 1*1024*1024,
		accept: 'jpg,png',
		ok: function(res){
			console.log('ok',res);
		},
		cancel: function(res){
			console.log('cancel',res);
		},
		thisArg: this,
	});
})

file(config)

  • config Object 配置参数
    • upload_url String 上传接口地址。查看详细介绍
    • filelist_url String 后台文件列表地址。查看详细介绍
    • max_file Number 可以上传或者选择的文件数量,默认为1。
    • max_size Number 文件上传的最大大小,设定到小于服务器限制。大于该大小的文件会进行分段上传,默认1010241024(10M)
    • name String 上传文件的字段的key,(默认值:file)
    • accept String 文件上传和列表限制的文件后缀名,逗号分隔。查看详细介绍
    • thisArg Object ok和cancel回调函数的this
    • ok Function 确认按钮回调函数,接收一个参数:
      • files Array 选择的文件地址列表,数组
    • cancel Function 取消按钮回调函数。无参数
  • 返回 underfind

调起插件界面,插件效果和传入的配置参数相关

配置参数说明

upload_url

请求参数格式

{
	"file" : "文件二进制数据"
}

返回参数格式

{
	"code": 1, // 1表示上传成功,0表示上传失败
	"msg": "", //提示信息,一般只有失败才给予提示
	"data": ["文件1的url","文件2的url",...] // 文件url地址列表,数组
}

filelist_url

请求参数格式

{
	"accept" : "配置参数的accept值",
	"dir" : "文件目录名称",
}

返回参数格式

{
	"code": 1, // 1表示上传成功,0表示上传失败
	"msg": "", //提示信息,一般只有失败才给予提示
	"data": {
		"dirs": ["目录1","目录2",...], // 目录列表,数组。用于点击目录的时候,发送filelist_url请求的dir参数
		"files": ["文件1的url","文件2的url",...] // 文件url地址列表,数组
	}
}

accept

由于MMIME类型不便记忆,所以文件类型限制采用文件后缀名,包括: jpg、jpeg、png、gif、ico、webp、 mp4、avi、wmv、 mp3、aif、aiff、wav、 wma、 txt、html、htm、js、css、xml、jsp、asp、pdf ppt、xls、doc、pptx、xlsx、docx 未完待续...