feat(upload): integrate upload service for chat image validation and S3 uploads
- Added UploadService to handle image uploads and validation for chat messages. - Updated ChatService and MessageService to utilize UploadService for validating image segments in messages. - Enhanced wire generation to inject UploadService into relevant services. - Introduced UploadImageBytes method in UploadService for uploading images directly from memory. - Added TrustedPublicURLPrefix method in S3 Client for generating public URLs for uploaded images.
This commit is contained in:
@@ -88,6 +88,18 @@ func (c *Client) UploadData(ctx context.Context, objectName string, data []byte,
|
||||
return fmt.Sprintf("%s://%s/%s/%s", scheme, c.domain, c.bucket, objectName), nil
|
||||
}
|
||||
|
||||
// TrustedPublicURLPrefix 本站公开对象 URL 前缀(scheme://domain/bucket/),用于校验聊天图片等仅引用本地上传资源。
|
||||
func (c *Client) TrustedPublicURLPrefix() string {
|
||||
if c == nil || c.domain == "" || c.bucket == "" {
|
||||
return ""
|
||||
}
|
||||
scheme := "https"
|
||||
if c.domain == c.bucket {
|
||||
scheme = "http"
|
||||
}
|
||||
return fmt.Sprintf("%s://%s/%s/", scheme, c.domain, c.bucket)
|
||||
}
|
||||
|
||||
// GetURL 获取文件URL - 使用自定义域名
|
||||
func (c *Client) GetURL(ctx context.Context, objectName string) (string, error) {
|
||||
// 使用自定义域名构建URL,包含bucket名称
|
||||
|
||||
Reference in New Issue
Block a user