All Projects → gaoyuyue → Myuploader

gaoyuyue / Myuploader

Licence: apache-2.0
单文件上传,多文件上传,大文件上传,断点续传,文件秒传,图片上传

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Myuploader

Vue Admin Manager
整合 vue,element,echarts,video,bootstrap(AdminLTE),admin等,搭建的后台管理系统
Stars: ✭ 153 (-21.54%)
Mutual labels:  element-ui
El Form Renderer
🎩A data-driven dynamic and complex form solution
Stars: ✭ 163 (-16.41%)
Mutual labels:  element-ui
Egrid
对 element-ui table 组件的封装
Stars: ✭ 175 (-10.26%)
Mutual labels:  element-ui
Fantastic Admin
一款开箱即用的 Vue 中后台管理系统框架,基于ElementUI,兼容PC、移动端,vue-admin, vue-element-admin, vue后台
Stars: ✭ 153 (-21.54%)
Mutual labels:  element-ui
Django Vue Admin
基于RBAC模型权限控制的中小型应用的基础开发平台,前后端分离,后端采用django+django-rest-framework,前端采用vue+ElementUI,移动端采用uniapp+uView(可发布h5和小程序).
Stars: ✭ 157 (-19.49%)
Mutual labels:  element-ui
Vue Element Ui Scaffold Webpack4
vue下基于webpack4构建的多页面、多环境方案脚手架项目(使用了element-ui,可替换为其他)
Stars: ✭ 171 (-12.31%)
Mutual labels:  element-ui
Hexo Theme Lite
Keep Calm, Light and Writing. Light Hexo Theme.
Stars: ✭ 148 (-24.1%)
Mutual labels:  element-ui
Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (-3.59%)
Mutual labels:  element-ui
El Tree Select
基于element-ui2.x扩展下拉树
Stars: ✭ 159 (-18.46%)
Mutual labels:  element-ui
Simpleui
A modern theme based on vue+element-ui for django admin.一款基于vue+element-ui的django admin现代化主题。全球20000+网站都在使用!喜欢可以点个star✨
Stars: ✭ 2,418 (+1140%)
Mutual labels:  element-ui
Nodeplatform Eggjs
基于egg.js编写的node平台,演示地址不要乱搞啊
Stars: ✭ 155 (-20.51%)
Mutual labels:  element-ui
Lb Element Table
基于element-ui table二次封装表格组件
Stars: ✭ 158 (-18.97%)
Mutual labels:  element-ui
Vue Tree
vue element-ui tree component expand
Stars: ✭ 172 (-11.79%)
Mutual labels:  element-ui
Webadmin
基于Vue.js 2.x系列 + Element UI 的后台管理系统解决方案。
Stars: ✭ 153 (-21.54%)
Mutual labels:  element-ui
Onlinejudgefe
A multiple pages app built for OnlineJudge
Stars: ✭ 175 (-10.26%)
Mutual labels:  element-ui
Vue.netcore
.NetCore+Vue2/Vue3+Element plus,前后端分离,不一样的快速开发框架;提供Vue2、Vue3版本,。http://www.volcore.xyz/
Stars: ✭ 2,338 (+1098.97%)
Mutual labels:  element-ui
Frostmourne
frostmourne是基于Elasticsearch, InfluxDB数据,Mysql数据的监控,报警,分析系统. Monitor & alert & alarm & analyze for Elasticsearch && InfluxDB Log Data。主要使用springboot2 + vue-element-admin。 https://frostmourne-demo.github.io/
Stars: ✭ 166 (-14.87%)
Mutual labels:  element-ui
Vue Electron
vue-blog client,base on vue-electron,axios, vuex, vue-router.
Stars: ✭ 193 (-1.03%)
Mutual labels:  element-ui
Element Patch
An extension package based on vue and element-ui. 一个基于 vue 与 element-ui 的扩展包,提供数据驱动的表单渲染,菜单渲染,表格拖拽,权限控制等功能
Stars: ✭ 187 (-4.1%)
Mutual labels:  element-ui
Ruoyi
基于开源项目RuoYi-Vue,扩展开发添加新业务功能。基于SpringBoot,Spring Security,JWT,Vue & Element 的前后端分离权限管理系统
Stars: ✭ 174 (-10.77%)
Mutual labels:  element-ui

MyUploader

单文件上传,多文件上传,大文件上传,断点续传,文件秒传,图片上传

后端项目地址: https://github.com/gaoyuyue/MyUploader-Backend

Build Status GitHub license

简介

项目采用前后端分离的方式进行开发,实现了几种常用的文件上传功能。 前端采用 vue.js + plupload + element-ui 实现了文件在浏览器端的发送, 后端采用 spring boot + spring + spring mvc + mybatis 实现了文件在服务器端的接收和存储。

本项目为前端实现

效果图

演示地址: https://gaoyuyue.github.io/MyUploader

ps: 用git pages搭建的静态页面,只能演示前端功能

单文件上传

多文件上传

大文件上传

断点续传

文件秒传

图片上传

前端实现

组件列表

引入plupload

plupload版本: 2.3.6

官方文档: https://www.plupload.com/docs/

中文文档: http://www.phpin.net/tools/plupload/

为了方便使用我将plupload封装为成一个vue组件Uploader.vue

例子:

<template>
    <div>
      <uploader
        browse_button="browse_button"
        :url="server_config.url+'/File/'"
        @inputUploader="inputUploader"
      />
      <el-button id="browse_button" type="primary">选择文件</el-button>
      <span v-for="file in files">{{file.name}}</span>
      <el-button type="danger" @click="up.start()">开始上传</el-button>
    </div>
</template>

<script>
  import Uploader from './Uploader'
  export default {
    name: "FileUpload",
    data() {
      return {
        server_config: this.global.server_config,
        files:[],
        up: {}
      }
    },
    methods: {
      inputUploader(up) {
        this.up = up;
        this.files = up.files;
      }
    },
    components: {
      'uploader': Uploader
    },
  }
</script>

<style scoped>
</style>

使用Uploader组件必须要配置的参数:

  • browse_button: 选择文件button的id
  • url: 文件上传地址
  • inputUploader方法: 用于获取uploader对象

为了获取uploader对象,自定义了inputUploader方法,需要在引用Uploader.vue的组件中实现inputUploader方法,inputUploader方法中传入了一个参数即uploader对象。关于uploader对象及其他配置参数请参考plupload官方文档

计算文件MD5值(用于文件妙传)

采用js-spark-md5.js, 项目地址: https://github.com/satazor/js-spark-md5

file-md5.js

'use strict';

import '../plugins/js-spark-md5.js'

export default function (file, callback) {
  var blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice,
    file = file,
    chunkSize = 2097152,                             // Read in chunks of 2MB
    chunks = Math.ceil(file.size / chunkSize),
    currentChunk = 0,
    spark = new SparkMD5.ArrayBuffer(),
    fileReader = new FileReader();

  fileReader.onload = function (e) {
    console.log('read chunk nr', currentChunk + 1, 'of', chunks);
    spark.append(e.target.result);                   // Append array buffer
    currentChunk++;

    if (currentChunk < chunks) {
      loadNext();
    } else {
      callback(null, spark.end());
      console.log('finished loading');
    }
  };

  fileReader.onerror = function () {
    callback('oops, something went wrong.');
  };

  function loadNext() {
    var start = currentChunk * chunkSize,
      end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize;

    fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
  }

  loadNext();
};

文件秒传: 在添加文件后计算文件的MD5值,在文件上传前先向服务器传送MD5值查询此文件是否已上传,如果文件存在返回false将文件状态置为已上传,否则上传文件。

图片预览

使用FileReader读取文件并转成Base64编码字符串, 填入<image/>标签的src属性上,即可实现图片预览功能。

file-url.js

export default function (file, callback) {
  if (!file || !/image\//.test(file.type)) return;
  let fileReader = new FileReader();
  fileReader.onload = function () {
    callback(null,fileReader.result);
  };
  fileReader.onerror = function () {
    callback('oops, something went wrong.');
  };
  fileReader.readAsDataURL(file);
}
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].