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

gc_cos_lib

v1.2.3

Published

Downloads

9

Readme

绿云上传基本类库

简介

支持上传到七牛、阿里云、腾讯云并记录日志

安装

npm install gc_cos_lib --save

使用

直接使用

    import UploadFile from "gc_cos_lib"

    // 普通上传
    const file = file  // iview中beforeUpload 事件中获取,注意返回false阻止默认上传
    // uniapp中获取文件
    const file = res.tempFiles[0];
    const upload = new UploadFile({
        file,                      // 需要上传的文件
        env: process.env.NODE_ENV, // 环境变量,与地址服务中配置的name一致
        unitCode: "GCBZG",
        fileType: "IMAGE"   // 上传类型
    });

    const res = await upload.upload(); //上传并记录日志,详见res数据实力

    if (res.success) {
        // do something
    }
    // or 手动记录日志

    const res = await upload.upload(false); //上传并手动记录日志
    if (res.success) {
        // do something
        upload.record({id:123}); // 记录日志 并带入自定义数据
    }

     // 上传进度显示 目前只支持七牛云
    const res = await upload.upload(false,(res)=>{
        const { percent } = res;
        // 上传进度处理
    });

分离使用

// 无上传 单纯记日志(删除、修改等)
const upload = new UploadFile({
    env: "development",
    unitCode: "GREENCLOUD"
});
console.log(upload);
const res = await upload.record({ id: 123 });

res 回复数据示例

{
    "success": true,      // 上传是否成功 失败为false
    "name": "1701242697159.jpg", // 图片名字
    "url": "https://imokkkk-1305920415.cos.ap-shanghai.myqcloud.com/static/user/1701851395115_1701242697159.jpg",  // 上传后正式访问地址
    "channel": "TENCENT", //  上传渠道
    "fileType": "OTHER"   //  上传类型
}

参数说明

| 属性 | 说明 | 类型 | 默认值 | | :-------: | :------------: | :----: | :----: | | file | 上传的文件 | file | / | | dataPath | axios返回数据路径 | string | data | | point | 点位信息 | Object | {system: "UC", page: "USER",position: "Avatar",bizRelObject: "用户", bizRelObjectId: "user111" } | | fileType | 类型: 图片、视频、文件(IMAGE/VIDEO/OTHER ) | String | IMAGE | | unitCode | UC单位信息,不传token可以传这个 | String | / | | env | 当前环境变量 development、production等 对应地址服务name | String | development | | token | 绿云uctoken,与上两个参数互斥,只支持浏览器环境使用 | String | / | | useOriginFileName | 是否采用原有文件名 | String | false |

独立上传

const upload = new UploadFile({
    file,
    fileType: "IMAGE" // 上传类型
});

const res = await upload.uploadFile({
    channel: "QINIU", // 上传渠道 QINIU、TENCENT、ALIYUN,必填
    domain: "https://dev-ht-img.songtsam.com", // 七牛云链接域名,可选 可自己拼接
    path: "base_journey/emergency/jugement/", // 七牛云存储位置,QINIU必填
    token: "123", // 七牛云上传token,QINIU必填
    host: "123" // 腾讯云或者阿里云签名上传地址,TENCENT、ALIYUN,必填
});