Giter VIP home page Giter VIP logo

nodeupload's Introduction

大文件上传Demo

Usage

npm install
npm start

Flow

----客户端-----------------------------------------------------服务端------
-                                                                        -
-  -生成MD5-                                                             -
-                                                                        -
-  -MD5-                -发送MD5>                 --------------------   -
-                                                 -                  -   -
-  -上传成功end-              <是-                 -检测文件是否存在    -   -
-                                                 -断点续传检测       -   -
-  ------   <-文件不存在(返回需要继续上传的分片)--    -无上传记录返回0分片 -   -
-  -上传-                                          -有则返回上次断点位置-   -
-  -     -                                        --------------------   -
-  -      -                                                              -
-  -若     -          ->->------------                                   -
-  -还有分片 -             -上传分片   -                                   -
-  -继续上传  -            -参数      -                                   -
-  -          -           -   md5    -                                   -
-  -否则       -          -   total  -                                   -
-  -请求       -          -   current-                                   -
-  -合并文件  -            -   file   -            --------------------   -
-  -       -              ---------------->       -                  -   -
-  -     -                                        -保存当前分片       -   -
-  -    -                                         -                  -   -
-  ------             <--返回下一个分片位置---      --------------------   -
-                                                                        -
-                                                                        -
-  ----------                                                            -
-  - 请求    -                                                ---------  -
-  - 合并    -          -md5->                                -合并文件-  -
-  - 文件    -                                                ---------  -
-  ----------                                                            -
-                                                                        -
----客户端-----------------------------------------------------服务端------

介绍

直接使用multipart/form-data文件上传

  • 适合小文件上传
  • 大文件上传中断后需要重新上传
  • http请求有超时时间、超时就上传失败,需要服务端和客户端双重设置

文件分片上传

  • 可以实现断点续传
  • 利用md5实现秒传功能(缺陷:md5值不能唯一对应文件)

流程

  1. 客户端校验md5值
  2. 请求发送MD5值
  3. 服务端返回md5校验结果(文件已存在,断点续传,文件不存在)
  4. 循环上传文件分片,服务端循环保存
  5. 上传完毕,发送上传完毕确认
  6. 服务端合并文件
  7. 下载并查看
  8. 完成

nodeupload's People

Contributors

curiositycigar avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.