断点续传示例
golang版本
package main
import (
"os"
"fmt"
"github.com/eventials/go-tus"
)
func main() {
f, err := os.Open("100m")
if err != nil {
panic(err)
}
defer f.Close()
client, err := tus.NewClient("http://10.1.5.9:8080/big/upload/", nil)
fmt.Println(err)
upload, err := tus.NewUploadFromFile(f)
fmt.Println(err)
uploader, err := client.CreateUpload(upload)
fmt.Println(err)
fmt.Println( uploader.Upload())
}
`
javascript版本 更多请查阅
<html>
<head>
<meta charset="utf-8" />
<title>go-fastdfs</title>
<style>form { bargin } .form-line { display:block;height: 30px;margin:8px; } #stdUpload {background: #fafafa;border-radius: 10px;width: 745px; }</style>
<link href="https://transloadit.edgly.net/releases/uppy/v0.30.0/dist/uppy.min.css" rel="stylesheet">
</head>
<body>
<div>断点续传(如果文件很大时可以考虑)</div>
<div>
<div id="drag-drop-area"></div>
<script src="https://transloadit.edgly.net/releases/uppy/v0.30.0/dist/uppy.min.js"></script>
<script>var uppy = Uppy.Core().use(Uppy.Dashboard, {
inline: true,
target: '#drag-drop-area'
}).use(Uppy.Tus, {
endpoint: '/big/upload/'
})
uppy.on('complete', (result) => {
})
uppy.setMeta({ auth_token: 'xx',callback_url:'http://127.0.0.1/callback' })
</script>
</div>
</body>
</html>
更多客户端请参考