MCPcopy Create free account
hub / github.com/asternic/wuzapi / GetPublicURL

Method GetPublicURL

s3manager.go:300–331  ·  view source on GitHub ↗

GetPublicURL generates public URL for S3 object

(userID, key string)

Source from the content-addressed store, hash-verified

298
299// GetPublicURL generates public URL for S3 object
300func (m *S3Manager) GetPublicURL(userID, key string) string {
301 _, config, ok := m.GetClient(userID)
302 if !ok {
303 return ""
304 }
305
306 // Use custom public URL if configured
307 if config.PublicURL != "" {
308 return fmt.Sprintf("%s/%s/%s", strings.TrimRight(config.PublicURL, "/"), config.Bucket, key)
309 }
310
311 // Generate standard S3 URL
312 if config.PathStyle {
313 return fmt.Sprintf("%s/%s/%s",
314 strings.TrimRight(config.Endpoint, "/"),
315 config.Bucket,
316 key)
317 }
318
319 // Virtual hosted-style URL
320 if strings.Contains(config.Endpoint, "amazonaws.com") {
321 return fmt.Sprintf("https://%s.s3.%s.amazonaws.com/%s",
322 config.Bucket,
323 config.Region,
324 key)
325 }
326
327 // For other S3-compatible services
328 endpoint := strings.TrimPrefix(config.Endpoint, "https://")
329 endpoint = strings.TrimPrefix(endpoint, "http://")
330 return fmt.Sprintf("https://%s.%s/%s", config.Bucket, endpoint, key)
331}
332
333// TestConnection tests S3 connection
334func (m *S3Manager) TestConnection(ctx context.Context, userID string) error {

Callers 1

ProcessMediaForS3Method · 0.95

Calls 1

GetClientMethod · 0.95

Tested by

no test coverage detected