New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fpm-plugin-upload

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fpm-plugin-upload

A Plugin Named [fpm-plugin-upload] For YF-FPM-SERVER~

latest
npmnpm
Version
1.1.1
Version published
Weekly downloads
3
200%
Maintainers
1
Weekly downloads
 
Created
Source

FPM-PLUGIN-UPLOAD

用于文件上传的插件

Install

npm i fpm-plugin-upload --save

Useage

  • default config

    {
      "upload":{
        "dir": "public/uploads/",
        "field": "upload",
        "uploadRouter": "/upload",
        "base": "/uploads/",
        "accept": [
          "application/octet-stream",
          "application/json",
          "application/zip",
          "application/x-zip-compressed",
          "image/png",
          "image/jpeg"],    // Allowed type
        "limit": 5,         // 5MB
      }
    }
    
  • Subscribe the event to save data:

    fpm.subscribe("#upload/success", (topic, data)=>{
      console.log(topic, data);
    });
    
    // the data:
    {
      fieldname: "upload",
      originalname: "test.json",
      encoding: "7bit",
      mimetype: "application/json",
      destination: "/Users/yfsoft/Product/fpm-plugin-upload/public/uploads",
      filename: "fcf56f1912879c4acbf03968b2b220dc.json",
      path: "/Users/yfsoft/Product/fpm-plugin-upload/public/uploads/fcf56f1912879c4acbf03968b2b220dc.json",
      size: 10,
      hash: "fcf56f1912879c4acbf03968b2b220dc"
    }
    
    // the data if qiniu :
    {
      fieldname: 'upload',
      originalname: 'test.json',
      encoding: '7bit',
      mimetype: 'application/json',
      hash: 'FvYprkS3s9z-1ETTY-Ym7fQR7Gmo',
      key: '408e19877d7b2c73_test.json',
      url: 'http://cdn.yunplus.io/408e19877d7b2c73_test.json',
      filename: '408e19877d7b2c73_test.json'
    }
    

Support Alicloud OSS

  • modify config.json

    {
      "upload": {
        "dir": "public/uploads/",
        "field": "upload",
        "uploadRouter": "/upload",
        "base": "/uploads/",
        "accept": [
            "application/octet-stream",
            "application/json",
            "application/zip",
            "application/x-zip-compressed",
            "image/png",
            "image/jpeg"],
        "limit": 5,
        "storage": "oss", // add oss
        "oss": {
          "bucket": "bucket-yunplus-io-object",
          "domain": "",
          "ACCESS_KEY": "*",
          "SECRET_KEY": "*",
          "zone": ""
        }
      }
    }
    

Support Qiniu

  • modify config.json

    {
      "upload":{
        "dir": "public/uploads/",
        "field": "upload",
        "uploadRouter": "/upload",
        "base": "/uploads/",
        "accept": [
            "application/octet-stream",
            "application/json",
            "application/zip",
            "application/x-zip-compressed",
            "image/png",
            "image/jpeg"],
        "limit": 5,
        "storage": "qiniu", // add qiniu
        "qiniu": {
          "bucket": "yfsoft",
          "domain": "cdn.yunplus.io",
          "ACCESS_KEY": "*",
          "SECRET_KEY": "*",
          "zone": "z2"
        }
      }
    }
    
  • install qiniu

    $ npm i qiniu --save

  • the resule of the uploaded

    {
      errno: 0,
      uploaded: true,
      url: 'http://cdn.yunplus.io/408e19877d7b2c73_test.json',
      data:{
        hash: '408e19877d7b2c73_test',
        path: 'http://cdn.yunplus.io/408e19877d7b2c73_test.json'
      }
    }
    

FAQs

Package last updated on 03 Jul 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