@@ -13,8 +13,8 @@ import (
1313 "github.com/json-iterator/go"
1414 log "github.com/sjqzhang/seelog"
1515 "github.com/syndtr/goleveldb/leveldb"
16- "github.com/tus /tusd"
17- "github.com/tus /tusd/filestore"
16+ "github.com/sjqzhang /tusd"
17+ "github.com/sjqzhang /tusd/filestore"
1818 "io"
1919 "io/ioutil"
2020 slog "log"
@@ -3359,37 +3359,59 @@ func (this *Server) HeartBeat(w http.ResponseWriter, r *http.Request) {
33593359func (this * Server ) Index (w http.ResponseWriter , r * http.Request ) {
33603360 var (
33613361 uploadUrl string
3362+ uploadBigUrl string
33623363 )
33633364 uploadUrl = "/upload"
3365+ uploadBigUrl = CONST_BIG_UPLOAD_PATH_SUFFIX
33643366 if Config ().EnableWebUpload {
33653367 if Config ().SupportGroupManage {
33663368 uploadUrl = fmt .Sprintf ("/%s/upload" , Config ().Group )
3369+ uploadBigUrl = fmt .Sprintf ("/%s%s" , Config ().Group ,CONST_BIG_UPLOAD_PATH_SUFFIX )
33673370 }
33683371 fmt .Fprintf (w ,
33693372 fmt .Sprintf (`<html>
3370- <head>
3371- <meta charset="utf-8"></meta>
3372- <title>Uploader</title>
3373- <style>
3374- form {
3375- bargin
3376-
3377- }
3378- .form-line {
3379- display:block;
3380- }
3381- </style>
3382- </head>
3383- <body>
3384- <form action="%s" method="post" enctype="multipart/form-data">
3385- <span class="form-line">文件(file):<input type="file" id="file" name="file" ></span>
3386- <span class="form-line">场景(scene):<input type="text" id="scene" name="scene" value="%s"></span>
3387- <span class="form-line">输出(output):<input type="text" id="output" name="output" value="json"></span>
3388- <span class="form-line">自定义路径(path):<input type="text" id="path" name="path" value=""></span>
3389- <input type="submit" name="submit" value="upload">
3390- </form>
3391- </body>
3392- </html>` , uploadUrl , Config ().DefaultScene ))
3373+
3374+ <head>
3375+ <meta charset="utf-8" />
3376+ <title>Uploader</title>
3377+ <style>form { bargin } .form-line { display:block;height: 30px;margin:8px; } #stdUpload {background: #fafafa;border-radius: 10px;width: 745px; }</style>
3378+ <link href="https://transloadit.edgly.net/releases/uppy/v0.30.0/dist/uppy.min.css" rel="stylesheet"></head>
3379+
3380+ <body>
3381+ <div>标准上传</div>
3382+ <div id="stdUpload">
3383+
3384+ <form action="%s" method="post" enctype="multipart/form-data">
3385+ <span class="form-line">文件(file):
3386+ <input type="file" id="file" name="file" /></span>
3387+ <span class="form-line">场景(scene):
3388+ <input type="text" id="scene" name="scene" value="%s" /></span>
3389+ <span class="form-line">输出(output):
3390+ <input type="text" id="output" name="output" value="json" /></span>
3391+ <span class="form-line">自定义路径(path):
3392+ <input type="text" id="path" name="path" value="" /></span>
3393+ <input type="submit" name="submit" value="upload" /></form>
3394+ </div>
3395+ <div>断点续传</div>
3396+ <div>
3397+
3398+ <div id="drag-drop-area"></div>
3399+ <script src="https://transloadit.edgly.net/releases/uppy/v0.30.0/dist/uppy.min.js"></script>
3400+ <script>var uppy = Uppy.Core().use(Uppy.Dashboard, {
3401+ inline: true,
3402+ target: '#drag-drop-area'
3403+ }).use(Uppy.Tus, {
3404+ endpoint: '%s'
3405+ })
3406+
3407+ uppy.on('complete', (result) => {
3408+ // console.log(result) console.log('Upload complete! We’ve uploaded these files:', result.successful)
3409+ })
3410+ </script>
3411+ </div>
3412+ </body>
3413+
3414+ </html>` , uploadUrl , Config ().DefaultScene ,uploadBigUrl ))
33933415 } else {
33943416 w .Write ([]byte ("web upload deny" ))
33953417 }
@@ -3541,6 +3563,9 @@ func (this *Server) initTus() {
35413563 panic ("initTus" )
35423564 }
35433565
3566+
3567+
3568+
35443569 go func () {
35453570 for {
35463571 if fi , err := fileLog .Stat (); err != nil {
@@ -3566,7 +3591,26 @@ func (this *Server) initTus() {
35663591 bigDir = fmt .Sprintf ("/%s%s" , Config ().Group , CONST_BIG_UPLOAD_PATH_SUFFIX )
35673592 }
35683593 composer := tusd .NewStoreComposer ()
3594+
3595+ // support raw tus upload and download
3596+ store .GetReaderExt = func (id string ) (io.Reader , error ) {
3597+ if fi , err := this .GetFileInfoFromLevelDB (id ); err != nil {
3598+ log .Error (err )
3599+ return nil , err
3600+ } else {
3601+ fp := DOCKER_DIR + fi .Path + "/" + fi .ReName
3602+ if this .util .FileExists (fp ) {
3603+ log .Info (fmt .Sprintf ("download:%s" ,fp ))
3604+ return os .Open (fp )
3605+ }
3606+ return nil , errors .New (fmt .Sprintf ("%s not found" , fp ))
3607+ }
3608+ }
3609+
3610+
35693611 store .UseIn (composer )
3612+
3613+
35703614 handler , err := tusd .NewHandler (tusd.Config {
35713615 Logger : l ,
35723616 BasePath : bigDir ,
0 commit comments