1.0.2 • Published 2 years ago

allvalue-cdn v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

AllValue File Upload SDK

Usage

Get upload token

AllValue Api: https://apidocs.allvalue.com/oauth

AllValue Api Demo: https://admin.allvalue.com/admin/graphql-demo

mutation {
  fileUploadsCreate(input:{
    fileName:""
    fileSize: 0
    mimeType:""
    resourceType:FILE
    
  }) {
    token
    parameters{
      name
    value
    }
  }
}

Install

npm

npm install allvalue-cdn

yarn

yarn add allvalue-cdn

CDN

<script src="https://su.yzcdn.cn/allvalue/open/sdk/js/upload/v1.0.0/index.js" crossorigin="anonymous"></script>

API params

参数名说明是否可选
file文件对象必选
token上传凭证必选
key文件前缀(示例:image/phone/big.png)必选
putExtra额外参数可选
const putExtra = {
  fname: "qiniu.txt", // 文件名
  mimeType: "text/plain", // 类型
};

Upload file according media type

ES6

import { uploadImage, uploadFile } from 'allvalue-cdn'

const onImageChange = (e) => {
    uploadImage(e.target.files[0], imageToken)
}

const onFileChange = (e) => {
    uploadFile(e.target.files[0], fileToken)
}


<input type="file" onChange={onImageChange} accept="image/*">
<input type="file" onChange={onImageChange} accept=".doc,.docx">

UMD

const onImageChange = (e) => {
    allValueUpload.uploadImage(e.target.files[0], imageToken)
}

const onFileChange = (e) => {
    allValueUpload.uploadFile(e.target.files[0], fileToken)
}


<input type="file" onChange={onImageChange} accept="image/*">
<input type="file" onChange={onImageChange} accept=".doc,.docx">
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago