diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a3d8aca..301d317 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,3 +59,18 @@ jobs: run: | docker build -t tusproject/tusd:$GITHUB_SHA . docker push tusproject/tusd:$GITHUB_SHA + - name: Tag docker image with release tag + if: startsWith(github.ref, 'refs/tags/') + run: | + # Extract tag name: https://stackoverflow.com/a/58178121 + TAG_NAME="${GITHUB_REF#refs/*/}" + docker tag tusproject/tusd:$GITHUB_SHA tusproject/tusd:$TAG_NAME + docker push tusproject/tusd:$TAG_NAME + # Create latest tag if we have no pre-release + if [[ $TAG_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; + then + docker tag tusproject/tusd:$GITHUB_SHA tusproject/tusd:latest + docker push tusproject/tusd:latest + fi + shell: bash + diff --git a/cmd/tusd/cli/flags.go b/cmd/tusd/cli/flags.go index b80a18c..1e2c597 100644 --- a/cmd/tusd/cli/flags.go +++ b/cmd/tusd/cli/flags.go @@ -82,7 +82,7 @@ func ParseFlags() { flag.BoolVar(&Flags.S3DisableSSL, "s3-disable-ssl", false, "Disable SSL and only use HTTP for communication with S3 (experimental and may be removed in the future)") flag.IntVar(&Flags.S3ConcurrentPartUploads, "s3-concurrent-part-uploads", 10, "Number of concurrent part uploads to S3 (experimental and may be removed in the future)") flag.StringVar(&Flags.GCSBucket, "gcs-bucket", "", "Use Google Cloud Storage with this bucket as storage backend (requires the GCS_SERVICE_ACCOUNT_FILE environment variable to be set)") - flag.StringVar(&Flags.GCSObjectPrefix, "gcs-object-prefix", "", "Prefix for GCS object names (can't contain underscore character)") + flag.StringVar(&Flags.GCSObjectPrefix, "gcs-object-prefix", "", "Prefix for GCS object names") flag.StringVar(&Flags.AzStorage, "azure-storage", "", "Use Azure BlockBlob Storage with this container name as a storage backend (requires the AZURE_ACCOUNT_NAME and AZURE_ACCOUNT_KEY environment variable to be set)") flag.StringVar(&Flags.AzContainerAccessType, "azure-container-access-type", "", "Access type when creating a new container if it does not exist (possible values: blob, container, '')") flag.StringVar(&Flags.AzBlobAccessTier, "azure-blob-access-tier", "", "Blob access tier when uploading new files (possible values: archive, cool, hot, '')") diff --git a/pkg/gcsstore/gcsservice.go b/pkg/gcsstore/gcsservice.go index 4667622..3acbcbd 100644 --- a/pkg/gcsstore/gcsservice.go +++ b/pkg/gcsstore/gcsservice.go @@ -351,7 +351,11 @@ loop: if strings.HasSuffix(objAttrs.Name, "info") { continue } - split := strings.Split(objAttrs.Name, "_") + + fileNameParts := strings.Split(objAttrs.Name, "/") + fileName := fileNameParts[len(fileNameParts)-1] + + split := strings.Split(fileName, "_") // If the object name does not split on "_", we have a composed object. // If the object name splits on "_" in to four pieces we diff --git a/pkg/gcsstore/gcsservice_test.go b/pkg/gcsstore/gcsservice_test.go index eeffe15..2c91430 100644 --- a/pkg/gcsstore/gcsservice_test.go +++ b/pkg/gcsstore/gcsservice_test.go @@ -447,7 +447,7 @@ func TestFilterObject(t *testing.T) { defer gock.Off() resp := googleBucketResponse{[]googleObjectResponse{ - googleObjectResponse{Name: "test-prefix_1"}, + googleObjectResponse{Name: "test_directory/test-prefix_1"}, }} gock.New("https://www.googleapis.com"). diff --git a/pkg/handler/head_test.go b/pkg/handler/head_test.go index 59da085..b5c83bb 100644 --- a/pkg/handler/head_test.go +++ b/pkg/handler/head_test.go @@ -48,9 +48,10 @@ func TestHead(t *testing.T) { }, Code: http.StatusOK, ResHeader: map[string]string{ - "Upload-Offset": "11", - "Upload-Length": "44", - "Cache-Control": "no-store", + "Upload-Offset": "11", + "Upload-Length": "44", + "Content-Length": "44", + "Cache-Control": "no-store", }, }).Run(handler, t) diff --git a/pkg/handler/unrouted_handler.go b/pkg/handler/unrouted_handler.go index ba2fb42..6c5f52b 100644 --- a/pkg/handler/unrouted_handler.go +++ b/pkg/handler/unrouted_handler.go @@ -260,9 +260,9 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler { } // Test if the version sent by the client is supported - // GET methods are not checked since a browser may visit this URL and does - // not include this header. This request is not part of the specification. - if r.Method != "GET" && r.Header.Get("Tus-Resumable") != "1.0.0" { + // GET and HEAD methods are not checked since a browser may visit this URL and does + // not include this header. GET requests are not part of the specification. + if r.Method != "GET" && r.Method != "HEAD" && r.Header.Get("Tus-Resumable") != "1.0.0" { handler.sendError(w, r, ErrUnsupportedVersion) return } @@ -472,6 +472,7 @@ func (handler *UnroutedHandler) HeadFile(w http.ResponseWriter, r *http.Request) w.Header().Set("Upload-Defer-Length", UploadLengthDeferred) } else { w.Header().Set("Upload-Length", strconv.FormatInt(info.Size, 10)) + w.Header().Set("Content-Length", strconv.FormatInt(info.Size, 10)) } w.Header().Set("Cache-Control", "no-store")