Skip to content

Instantly share code, notes, and snippets.

@leapar
Last active November 22, 2017 01:30
Show Gist options
  • Save leapar/efc018e2e63bf069a9372cfb8e70dd38 to your computer and use it in GitHub Desktop.
Save leapar/efc018e2e63bf069a9372cfb8e70dd38 to your computer and use it in GitHub Desktop.
gun
@leapar
Copy link
Author

leapar commented Oct 12, 2017

upload

  1. libcurl libuv
    采用libuv的epoll方式实现的异步高性能libcurl发送数据的方法
    http://blog.csdn.net/lijinqi1987/article/details/53996129

@leapar
Copy link
Author

leapar commented Oct 13, 2017

大文件上传

问题:

如果有几百M,几G的文件上传,怎么做?同时还需要进行续传。

  1. 上传客户端进行文件分片,例如2g文件=2102410241024=2000 0001024拆分成1024个文件片
  2. 客户端进行多线程上传,同时记录已经完成的文件片
  3. 服务器支持/upload接口,保存每一个文件片uid_index.data
  4. 客户端发现所有文件片都已经上传完成,调用/over接口进行文件片合并,同时进行checksum文件校验
  5. 最后把上传完毕的文件同步到hdfs中

支持文件分片上传的js客户端有:

  1. jQuery-File-Upload https://blueimp.github.io/jQuery-File-Upload/
  2. webuploader http://fex.baidu.com/webuploader/
  3. fineuploader https://fineuploader.com/

服务端代码:

  1. https://github.com/peinhu/AetherUpload-Laravel
  2. https://github.com/pionl/laravel-chunk-upload
  3. https://github.com/FineUploader/fineuploader-go-server
  4. https://github.com/FineUploader/spring-boot-server

完整例子

  1. https://github.com/leapar/fineuploader

checksum

  1. https://github.com/satazor/js-spark-md5

@leapar
Copy link
Author

leapar commented Oct 13, 2017

fineuploader

  1. 浏览器最大连接数 http://www.cnblogs.com/xiaoxiapier/p/4505117.html
  2. 默认是3个 可以修改maxConnections 达到更多 https://docs.fineuploader.com/api/options.html#maxConnections
<script>
    // Some options to pass to the uploader are discussed on the next page
    var uploader = new qq.FineUploader({
        element: document.getElementById("uploader"),
        //element: document.getElementById("fineuploader-container"),
        request: {
            endpoint: "http://127.0.0.1:8080/upload"
        },
        deleteFile: {
            enabled: true,
            endpoint: "http://127.0.0.1:8080/upload"
        },
        maxConnections:5,
        chunking: {
            enabled: true,
            concurrent: {
                enabled: true
            },
            success: {
                endpoint: "http://127.0.0.1:8080/chunksdone"
            }
        },
        resume: {
            enabled: true
        },
        retry: {
            enableAuto: true,
            showButton: true
        }
    })
</script>

1

@leapar
Copy link
Author

leapar commented Oct 19, 2017

开启Threejs之旅 http://www.hewebgl.com/

@leapar
Copy link
Author

leapar commented Nov 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment