Tencent/WeKnora · error

failed to upload file to MinIO: %w

Error message

failed to upload file to MinIO: %w

What it means

MinIO PutObject failed while uploading the opened multipart file to the generated object key, meaning the object was not stored; network issues, bucket permissions, or size limits are typical causes and the failure is wrapped for the caller.

Source

Thrown at internal/application/service/file/minio.go:142

	file *multipart.FileHeader, tenantID uint64, knowledgeID string,
) (string, error) {
	// Generate object name
	ext := filepath.Ext(file.Filename)
	objectName := fmt.Sprintf("%d/%s/%s%s", tenantID, knowledgeID, uuid.New().String(), ext)

	// Open file
	src, err := file.Open()
	if err != nil {
		return "", fmt.Errorf("failed to open file: %w", err)
	}
	defer src.Close()

	// Upload file to MinIO
	_, err = s.client.PutObject(ctx, s.bucketName, objectName, src, file.Size, minio.PutObjectOptions{
		ContentType: file.Header.Get("Content-Type"),
	})
	if err != nil {
		return "", fmt.Errorf("failed to upload file to MinIO: %w", err)
	}

	return fmt.Sprintf("minio://%s/%s", s.bucketName, objectName), nil
}

// GetFile gets a file from MinIO
func (s *minioFileService) GetFile(ctx context.Context, filePath string) (io.ReadCloser, error) {
	objectName, err := s.parseMinioFilePath(filePath)
	if err != nil {
		return nil, err
	}
	obj, err := s.client.GetObject(ctx, s.bucketName, objectName, minio.GetObjectOptions{})
	if err != nil {
		return nil, fmt.Errorf("failed to get file from MinIO: %w", err)
	}
	return obj, nil
}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Check MinIO reachability and write permissions
  2. Verify bucket size/quota limits
  3. Retry the upload; the object key is new so no partial overwrite risk
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/application/service/file/minio.go:142 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/400cff6dcceabf4f. Report an issue: GitHub.