@lx-frontend/wx-upload-file
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

@lx-frontend/wx-upload-file

小程序文件上传库(仅支持上传,需单独获取上传配置)

Usage

在小程序中:

  1. 引入包
import { fileUpload } from '@lx-frontend/wx-upload-file'

上传图片

wx.chooseImage({
  'sizeType': ['compressed'],
  success: async (res) => {
    const [ localPath ] = res.tempFilePaths
    const upRes = await fileUpload({
      uploadUrl: 'https://a.b.com/v1/storage',
      uploadPath: 'a/image/2024-01-09/eubryuzf',
      uploadToken: 'bearer ey11111',
      uploadType: 'image'
      filePath: localPath
    })
    console.log('upRes', upRes)
  }
})

返回数据格式:

{
    "code":0,
    "data":[
        {
            "image":"https://xxxxx.png",
            "key":"",
            "thumbnail_image":"https://xxxx.png?x-oss-process=image/resize,w_300/quality,q_80",
            "upload_image":"https://test-images-cdn.lxusercontent.com/xxxx.png"
        }
    ],
    "message":"ok"
}

参数说明

参数 说明 类型 可选值 默认值 必填
uploadUrl 上传服务url String - -
uploadPath 上传存储path String - -
uploadToken 上传token String - -
uploadType 上传资源类型 String image/video/audio -
filePath 小程序为选取资源的 tempFilePaths 字段 String - -
customParams 自定义参数 String - -
cb uploadTask 回调 String - -

Readme

Keywords

none

Package Sidebar

Install

npm i @lx-frontend/wx-upload-file

Weekly Downloads

0

Version

0.0.3

License

ISC

Unpacked Size

12.8 kB

Total Files

11

Last publish

Collaborators

  • haiyulu
  • erica.liuyj
  • pok.h
  • chenzian
  • tomgou
  • azumia
  • jeely
  • lichao.franklee
  • mind29
  • yuki.liu
  • lixinleon
  • frontbot
  • owen.huang
  • tiny.tu
  • simba.wang