fix(go-server): ensure original filename can be deduced from tmp file (#17416)

This commit is contained in:
Erik Booij
2024-01-09 19:00:44 +01:00
committed by GitHub
parent 425011a50c
commit 90f3b24edc
4 changed files with 12 additions and 4 deletions

View File

@@ -169,7 +169,9 @@ func readFileHeaderToTempFile(fileHeader *multipart.FileHeader) (*os.File, error
defer formFile.Close()
file, err := os.CreateTemp("", fileHeader.Filename)
// Use .* as suffix, because the asterisk is a placeholder for the random value,
// and the period allows consumers of this file to remove the suffix to obtain the original file name
file, err := os.CreateTemp("", fileHeader.Filename+".*")
if err != nil {
return nil, err
}

View File

@@ -136,7 +136,9 @@ func readFileHeaderToTempFile(fileHeader *multipart.FileHeader) (*os.File, error
defer formFile.Close()
file, err := os.CreateTemp("", fileHeader.Filename)
// Use .* as suffix, because the asterisk is a placeholder for the random value,
// and the period allows consumers of this file to remove the suffix to obtain the original file name
file, err := os.CreateTemp("", fileHeader.Filename+".*")
if err != nil {
return nil, err
}

View File

@@ -140,7 +140,9 @@ func readFileHeaderToTempFile(fileHeader *multipart.FileHeader) (*os.File, error
defer formFile.Close()
file, err := os.CreateTemp("", fileHeader.Filename)
// Use .* as suffix, because the asterisk is a placeholder for the random value,
// and the period allows consumers of this file to remove the suffix to obtain the original file name
file, err := os.CreateTemp("", fileHeader.Filename+".*")
if err != nil {
return nil, err
}

View File

@@ -136,7 +136,9 @@ func readFileHeaderToTempFile(fileHeader *multipart.FileHeader) (*os.File, error
defer formFile.Close()
file, err := os.CreateTemp("", fileHeader.Filename)
// Use .* as suffix, because the asterisk is a placeholder for the random value,
// and the period allows consumers of this file to remove the suffix to obtain the original file name
file, err := os.CreateTemp("", fileHeader.Filename+".*")
if err != nil {
return nil, err
}