diff options
| author | chrislu <chris.lu@gmail.com> | 2025-12-01 13:34:43 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2025-12-01 13:34:43 -0800 |
| commit | 42b173fff9b8ffa84878cbf27223f7d583c26005 (patch) | |
| tree | c7acf409b22863585ebc3563a10f460b62326907 | |
| parent | 31214b2874d7c247a70de17dc12551697c784ca7 (diff) | |
| download | seaweedfs-42b173fff9b8ffa84878cbf27223f7d583c26005.tar.xz seaweedfs-42b173fff9b8ffa84878cbf27223f7d583c26005.zip | |
Rename -tus.path to -tusBasePath with default .tus
- Rename CLI flag from -tus.path to -tusBasePath
- Default to .tus (TUS enabled by default)
- Add -filer.tusBasePath option to weed server command
- Properly handle path prefix (prepend / if missing)
| -rw-r--r-- | test/tus/Makefile | 3 | ||||
| -rw-r--r-- | test/tus/README.md | 15 | ||||
| -rw-r--r-- | weed/command/filer.go | 2 | ||||
| -rw-r--r-- | weed/command/server.go | 1 | ||||
| -rw-r--r-- | weed/server/filer_server.go | 3 | ||||
| -rw-r--r-- | weed/server/filer_server_tus_handlers.go | 11 |
6 files changed, 22 insertions, 13 deletions
diff --git a/test/tus/Makefile b/test/tus/Makefile index 1a944a4f0..71b05e8ab 100644 --- a/test/tus/Makefile +++ b/test/tus/Makefile @@ -95,13 +95,12 @@ start-seaweedfs: check-binary > /tmp/seaweedfs-tus-volume.log 2>&1 & @sleep 3 - # Start filer server with TUS enabled + # Start filer server with TUS enabled (default tusBasePath is .tus) @echo "Starting filer server..." @nohup $(SEAWEEDFS_ROOT)/weed/weed filer \ -port=$(FILER_PORT) \ -master=127.0.0.1:$(MASTER_PORT) \ -ip=127.0.0.1 \ - -tus.path=/.tus \ > /tmp/seaweedfs-tus-filer.log 2>&1 & @sleep 5 diff --git a/test/tus/README.md b/test/tus/README.md index e948c06d1..cd014229e 100644 --- a/test/tus/README.md +++ b/test/tus/README.md @@ -42,17 +42,18 @@ TUS is an open protocol for resumable file uploads over HTTP. It allows clients ## Enabling TUS -TUS protocol support must be explicitly enabled when starting the filer server using the `-tus.path` flag: +TUS protocol support is enabled by default at `/.tus` path. You can customize the path using the `-tusBasePath` flag: ```bash -# Start filer with TUS enabled at /.tus path -weed filer -master=localhost:9333 -tus.path=/.tus +# Start filer with default TUS path (/.tus) +weed filer -master=localhost:9333 -# Or use a custom path -weed filer -master=localhost:9333 -tus.path=/uploads/tus -``` +# Use a custom path +weed filer -master=localhost:9333 -tusBasePath=uploads/tus -If `-tus.path` is not specified, TUS endpoints are disabled. +# Disable TUS by setting empty path +weed filer -master=localhost:9333 -tusBasePath= +``` ## Test Structure diff --git a/weed/command/filer.go b/weed/command/filer.go index d60312f5e..314bb83b6 100644 --- a/weed/command/filer.go +++ b/weed/command/filer.go @@ -110,7 +110,7 @@ func init() { f.diskType = cmdFiler.Flag.String("disk", "", "[hdd|ssd|<tag>] hard drive or solid state drive or any tag") f.allowedOrigins = cmdFiler.Flag.String("allowedOrigins", "*", "comma separated list of allowed origins") f.exposeDirectoryData = cmdFiler.Flag.Bool("exposeDirectoryData", true, "whether to return directory metadata and content in Filer UI") - f.tusPath = cmdFiler.Flag.String("tus.path", "", "TUS resumable upload endpoint path, e.g., /.tus (disabled if empty)") + f.tusPath = cmdFiler.Flag.String("tusBasePath", ".tus", "TUS resumable upload endpoint base path") // start s3 on filer filerStartS3 = cmdFiler.Flag.Bool("s3", false, "whether to start S3 gateway") diff --git a/weed/command/server.go b/weed/command/server.go index 47df30fc2..52f47ec32 100644 --- a/weed/command/server.go +++ b/weed/command/server.go @@ -129,6 +129,7 @@ func init() { filerOptions.downloadMaxMBps = cmdServer.Flag.Int("filer.downloadMaxMBps", 0, "download max speed for each download request, in MB per second") filerOptions.diskType = cmdServer.Flag.String("filer.disk", "", "[hdd|ssd|<tag>] hard drive or solid state drive or any tag") filerOptions.exposeDirectoryData = cmdServer.Flag.Bool("filer.exposeDirectoryData", true, "expose directory data via filer. If false, filer UI will be innaccessible.") + filerOptions.tusPath = cmdServer.Flag.String("filer.tusBasePath", ".tus", "TUS resumable upload endpoint base path") serverOptions.v.port = cmdServer.Flag.Int("volume.port", 8080, "volume server http listen port") serverOptions.v.portGrpc = cmdServer.Flag.Int("volume.port.grpc", 0, "volume server grpc listen port") diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go index d35485ad2..3d2db00ad 100644 --- a/weed/server/filer_server.go +++ b/weed/server/filer_server.go @@ -199,6 +199,9 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption) // TUS resumable upload protocol handler if option.TusPath != "" { tusPath := option.TusPath + if !strings.HasPrefix(tusPath, "/") { + tusPath = "/" + tusPath + } if !strings.HasSuffix(tusPath, "/") { tusPath += "/" } diff --git a/weed/server/filer_server_tus_handlers.go b/weed/server/filer_server_tus_handlers.go index 8fe93a6e7..294204696 100644 --- a/weed/server/filer_server_tus_handlers.go +++ b/weed/server/filer_server_tus_handlers.go @@ -37,7 +37,10 @@ func (fs *FilerServer) tusHandler(w http.ResponseWriter, r *http.Request) { path := r.URL.Path tusPrefix := fs.option.TusPath if tusPrefix == "" { - tusPrefix = "/.tus" + tusPrefix = ".tus" + } + if !strings.HasPrefix(tusPrefix, "/") { + tusPrefix = "/" + tusPrefix } // Check if this is an upload location (contains upload ID after {tusPrefix}/.uploads/) @@ -104,7 +107,10 @@ func (fs *FilerServer) tusCreateHandler(w http.ResponseWriter, r *http.Request) // Get TUS path prefix tusPrefix := fs.option.TusPath if tusPrefix == "" { - tusPrefix = "/.tus" + tusPrefix = ".tus" + } + if !strings.HasPrefix(tusPrefix, "/") { + tusPrefix = "/" + tusPrefix } // Determine target path from request URL @@ -366,4 +372,3 @@ func parseTusMetadata(header string) map[string]string { return metadata } - |
