All Projects → die-welle → Tiny Qiniu

die-welle / Tiny Qiniu

Licence: mit
A tiny qiniu sdk for uploading file.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Tiny Qiniu

Node Qiniu Sdk
七牛云SDK,使用 ES2017 async functions 来操作七牛云,接口名称与官方接口对应,轻松上手,文档齐全
Stars: ✭ 44 (+193.33%)
Mutual labels:  qiniu, promise, sdk
Uphold Sdk Android
Uphold Android SDK
Stars: ✭ 32 (+113.33%)
Mutual labels:  sdk, upload
miniprogram-network
Redefine the Network API of Wechat MiniProgram (小程序网络库)
Stars: ✭ 93 (+520%)
Mutual labels:  promise, upload
Cloudinary ios
Cloudinary iOS SDK
Stars: ✭ 133 (+786.67%)
Mutual labels:  sdk, upload
Qiniu
Qiniu sdk for Elixir
Stars: ✭ 60 (+300%)
Mutual labels:  qiniu, sdk
Laravel Storage Qiniu
Laravel 5 七牛存储组件(不再维护)
Stars: ✭ 70 (+366.67%)
Mutual labels:  qiniu, sdk
Uploadcare Php
PHP API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
Stars: ✭ 77 (+413.33%)
Mutual labels:  sdk, upload
Sy flutter qiniu storage
七牛云对象存储SDK,上传大文件,进度监听,取消上传
Stars: ✭ 68 (+353.33%)
Mutual labels:  qiniu, upload
tiny-qiniu-request
tiny-qiniu for rc-upload or antd upload component `customRequest` property
Stars: ✭ 13 (-13.33%)
Mutual labels:  upload, qiniu
react-file-input-previews-base64
This package provides an easy to use, ready to go and customizable wrapper around file input, with option for image previews and returning file as base64 string.
Stars: ✭ 15 (+0%)
Mutual labels:  base64, upload
Smartystreets Go Sdk
The official client libraries for accessing SmartyStreets APIs from Go.
Stars: ✭ 11 (-26.67%)
Mutual labels:  sdk
Appkefu android demo v4
微客服 安卓客服demo 4.x 版本 (IM, SDK, ChatUI, helpdesk, 客服系统 )
Stars: ✭ 11 (-26.67%)
Mutual labels:  sdk
Voucherify Android Sdk
Android SDK for Voucherify - coupons, vouchers, promo codes
Stars: ✭ 13 (-13.33%)
Mutual labels:  sdk
Resingo
[UNMAINTAINED] Unofficial golang sdk for resin.io
Stars: ✭ 14 (-6.67%)
Mutual labels:  sdk
Itunes smartplaylist
iTunes Smart playlist parser with Python. Convert to Kodi xsp smart playlists.
Stars: ✭ 10 (-33.33%)
Mutual labels:  base64
Zhima
芝麻信用商家服务PHP版SDK。目前为止,是github上最好用的php版SDK
Stars: ✭ 13 (-13.33%)
Mutual labels:  sdk
Fileup
FileUp - JQuery File Upload
Stars: ✭ 10 (-33.33%)
Mutual labels:  upload
Js Sdk
A bridge between the Yebo E-Commerce and your website.
Stars: ✭ 10 (-33.33%)
Mutual labels:  sdk
Vst3sdk
VST 3 Plug-In SDK
Stars: ✭ 853 (+5586.67%)
Mutual labels:  sdk
Upload Image To Smms By Automator
Drag your image to me, I will upload it to SM.MS automatically and backup info to iCloud. 只需拖拽图片即可轻松上传至 SM.MS 图床并且复制链接,所有图片和链接信息会被备份至 iCloud 方便后期检索。
Stars: ✭ 15 (+0%)
Mutual labels:  upload

A tiny qiniu sdk for uploading file. (browser only)

Differences from qiniu.js

  • Smaller
  • No UI
  • Support upload base64 string

Requirements

  • Qiniu developer account
  • Promise polyfill for old version browser

Installing

Using npm:

$ npm install tiny-qiniu

Using yarn:

$ yarn add tiny-qiniu

Usage

TinyQiniu#constructor(options)

Exapmle

import TinyQiniu from 'tiny-qiniu';

const config = {
    bucket: 'my_bucket', // qiniu bucket name, requried

    /* one of `baseURL` or `mapResponse` is required */
    baseURL: 'http://cdn.awesome.com', // qiniu bucket domain, requried

    mapResponse: (data) => data, // a function to map final response data

    /* one of `uptoken`, `uptokenUrl`, `uptokenFunc` is required */

    // use a static uptoken string, it's NOT recommended
    uptoken: 'your_upload_token',

    // or use an url to dynamically get uptoken, should return json with `{ uptoken: 'uptoken_from_server' }`
    uptokenUrl: 'http://localhost/api/uptoken',

    // save zone
    // z0 - 华东 (by default), z1 - 华北, z2 - 华南, na0 - 北美
    zone: 'z2',

    // or use a function to dynamically return uptoken string
    uptokenFunc: () => {
        const fakeFetch = () => new Promise((resolve) => {
            setTimeout(() => resolve('my_uptoken'), 1000)
        });

        return fakeFetch('/fake/api'); // return a promise
    },

    mapUptoken: (data) => data.uptoken || data, // Optional, a function to map uptoken when fetch uptoken completed

    mapResponseURL: (url, hash, key, data) => url, // Optional, a function to map final url
};
const tinyQiniu = new TinyQiniu(config);

TinyQiniu#uploadFile(file[, options])

Upload with a file object. You can also provide a remote file name by adding options.key as the second argument. Returns a promise.

options (Object)
  • key (String): Remote file name
  • onProgress (Function): The function called periodically with information when an upload request before success completely.

Example

var file = document.querySelector('#fileInput').files[0];
tinyQiniu.uploadFile(file, { key: 'my_file_name' }).then((resp) => console.log(resp.url));

TinyQiniu#uploadBase64(base64String[, options])

Upload with a base64 string. You can also provide a remote file name by adding options.base64key as the second argument. Returns a promise.

NOTE base64key should provide a base64 string. You can use btoa() or some other library to generate it.

Exapmle

const base64Key = btoa('my_file_name');
tinyQiniu.uploadBase64(base64String, { base64key }).then((resp) => console.log(resp.url));

Available Zones

  • z0: upload.qiniup.com (default)
  • z1: upload-z1.qiniup.com
  • z2: upload-z2.qiniup.com
  • na0: upload-na0.qiniup.com

Please checkout https://developer.qiniu.com/kodo/manual/1671/region-endpoint for detail

Notes

  • It is recommended to setup a server to get uptoken for security. To setup a uptoken server, please checkout /test/server
  • If you are looking for a react component, tiny-qiniu-request is a good helper

Contributing

Please checkout the contributing page

ChangeLog

Please checkout the Releases page

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].