Files
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

2.7 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
s3_download function go infra 1.0.0 impure func S3Download(cfg S3Config, key string, dst io.Writer) error STUB. Descarga el objeto key desde un bucket S3-compatible y escribe su contenido en dst. Permite streaming directo a disco o a un HTTP response. Requiere github.com/aws/aws-sdk-go-v2.
s3
download
storage
cloud
stub
infra
pendiente-usar
S3Config_go_infra
false error_go_core
fmt
io
name desc
cfg S3Config con endpoint, bucket, credenciales y region
name desc
key key del objeto a descargar (ej: "images/foto.png")
name desc
dst writer donde se escribe el contenido (ej: os.File, http.ResponseWriter, bytes.Buffer)
nil si la descarga fue exitosa, error si fallo. STUB actual retorna siempre error "not implemented" false
functions/infra/s3_download.go

Estado

Stub. Para activar la implementacion real:

  1. Añadir las mismas dependencias que s3_upload.
  2. Reemplazar el cuerpo del stub por:
    func S3Download(cfg S3Config, key string, dst io.Writer) error {
        ctx := context.Background()
        awsCfg, err := awscfg.LoadDefaultConfig(ctx,
            awscfg.WithRegion(cfg.Region),
            awscfg.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
                cfg.AccessKey, cfg.SecretKey, "")),
        )
        if err != nil {
            return fmt.Errorf("s3_download: aws config: %w", err)
        }
        client := s3.NewFromConfig(awsCfg, func(o *s3.Options) {
            o.UsePathStyle = true
            if cfg.Endpoint != "" {
                scheme := "http"
                if cfg.UseSSL {
                    scheme = "https"
                }
                o.BaseEndpoint = aws.String(fmt.Sprintf("%s://%s", scheme, cfg.Endpoint))
            }
        })
        out, err := client.GetObject(ctx, &s3.GetObjectInput{
            Bucket: aws.String(cfg.Bucket),
            Key:    aws.String(key),
        })
        if err != nil {
            return fmt.Errorf("s3_download: get object: %w", err)
        }
        defer out.Body.Close()
        _, err = io.Copy(dst, out.Body)
        return err
    }
    

Ejemplo (con implementacion real)

f, _ := os.Create("./local/photo.png")
defer f.Close()
err := S3Download(cfg, "images/photo.png", f)

Notas

Soporta streaming — el dst puede ser un os.File, http.ResponseWriter, bytes.Buffer, o cualquier io.Writer. Para archivos grandes, escribir directamente al cliente HTTP evita cargarlo todo en memoria.