Skip to content

Commit

Permalink
or dont
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Funkhouser <[email protected]>
  • Loading branch information
golanglemonade committed Oct 15, 2024
1 parent 6c84565 commit 860244a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/objects/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

var (
errSeek = "could not seek to beginning of file; %w"
seekError = "could not seek to beginning of file"
)

// NewUploadFile function reads the content of the provided file path and returns a FileUpload object
Expand Down Expand Up @@ -108,7 +108,7 @@ func ComputeChecksum(data io.ReadSeeker) (string, error) {
}

if _, err := data.Seek(0, io.SeekStart); err != nil { // seek back to beginning of file
return "", fmt.Errorf(errSeek, err)
return "", fmt.Errorf("%s: %w", seekError, err)
}

return base64.StdEncoding.EncodeToString(hash.Sum(nil)), nil
Expand All @@ -119,7 +119,7 @@ func ComputeChecksum(data io.ReadSeeker) (string, error) {
// beginning and will seek back to the beginning after reading its content.
func DetectContentType(data io.ReadSeeker) (string, error) {
if _, err := data.Seek(0, io.SeekStart); err != nil { // seek back to beginning of file
return "", fmt.Errorf(errSeek, err)
return "", fmt.Errorf("%s: %w", seekError, err)
}

// the default return value will default to application/octet-stream if unable to detect the MIME type
Expand All @@ -129,7 +129,7 @@ func DetectContentType(data io.ReadSeeker) (string, error) {
}

if _, err := data.Seek(0, io.SeekStart); err != nil { // seek back to beginning of file
return "", fmt.Errorf(errSeek, err)
return "", fmt.Errorf("%s: %w", seekError, err)
}

return contentType.String(), nil
Expand Down

0 comments on commit 860244a

Please sign in to comment.