Unified/Blob: Allow direct access to UIDs (#101339)

This commit is contained in:
Ryan McKinley
2025-02-26 17:18:59 +03:00
committed by GitHub
parent d009795f1a
commit 8f37822050
6 changed files with 189 additions and 131 deletions

View File

@ -6,6 +6,7 @@ import (
"encoding/hex"
"fmt"
"net/http"
"time"
"github.com/google/uuid"
@ -57,6 +58,7 @@ func (b *backend) PutResourceBlob(ctx context.Context, req *resource.PutBlobRequ
err = b.db.WithTx(ctx, ReadCommitted, func(ctx context.Context, tx db.Tx) error {
_, err := dbutil.Exec(ctx, tx, sqlResourceBlobInsert, sqlResourceBlobInsertRequest{
SQLTemplate: sqltemplate.New(b.dialect),
Now: time.Now(),
Info: info,
Key: req.Resource,
ContentType: req.ContentType,
@ -83,6 +85,12 @@ func (b *backend) GetResourceBlob(ctx context.Context, key *resource.ResourceKey
ctx, span := b.tracer.Start(ctx, tracePrefix+"GetResourceBlob")
defer span.End()
if info == nil {
return &resource.GetBlobResponse{
Error: resource.NewBadRequestError("missing blob info"),
}, nil
}
rsp := &resource.GetBlobResponse{}
err := b.db.WithTx(ctx, ReadCommitted, func(ctx context.Context, tx db.Tx) error {
rows, err := dbutil.QueryRows(ctx, tx, sqlResourceBlobQuery, sqlResourceBlobQueryRequest{