Tencent/WeKnora · error
failed to upload file to TOS: %w
Error message
failed to upload file to TOS: %w
What it means
TOS PutObjectV2 failed while uploading the opened file (content type from header or extension fallback) to the generated joined object key, so the object was not stored; permissions, quota, or connectivity causes are wrapped in the error.
Source
Thrown at internal/application/service/file/tos.go:199
if err != nil {
return "", fmt.Errorf("failed to open file: %w", err)
}
defer src.Close()
contentType := file.Header.Get("Content-Type")
if contentType == "" {
contentType = utils.GetContentTypeByExt(ext)
}
_, err = s.client.PutObjectV2(ctx, &tos.PutObjectV2Input{
PutObjectBasicInput: tos.PutObjectBasicInput{
Bucket: s.bucketName,
Key: objectName,
ContentType: contentType,
},
Content: src,
})
if err != nil {
return "", fmt.Errorf("failed to upload file to TOS: %w", err)
}
return fmt.Sprintf("tos://%s/%s", s.bucketName, objectName), nil
}
func (s *tosFileService) SaveBytes(ctx context.Context, data []byte, tenantID uint64, fileName string, temp bool) (string, error) {
safeName, err := utils.SafeFileName(fileName)
if err != nil {
return "", fmt.Errorf("invalid file name: %w", err)
}
ext := filepath.Ext(safeName)
reader := bytes.NewReader(data)
targetBucket := s.bucketName
objectName := joinTOSObjectKey(
s.pathPrefix,
fmt.Sprintf("%d", tenantID),
"exports",View on GitHub (pinned to 988cbb0330)
Solutions
- Check TOS credentials and write permissions
- Verify bucket quota and network egress
- Retry the upload; the generated key makes retries idempotent-safe
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/application/service/file/tos.go:199 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/7989b27dfaadc40b.
Report an issue: GitHub.