(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, req *grpcapi.WriteContentRequest)
| 277 | } |
| 278 | |
| 279 | func handleWriteContentRequest(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, req *grpcapi.WriteContentRequest) *grpcapi.SessionResponse { |
| 280 | ctx, span := tracer.Start(ctx, "GRPCSession.WriteContent") |
| 281 | defer span.End() |
| 282 | |
| 283 | if authz.ContentAccessLevel() < auth.AccessLevelAppend { |
| 284 | return accessDeniedResponse() |
| 285 | } |
| 286 | |
| 287 | if strings.HasPrefix(req.GetPrefix(), manifest.ContentPrefix) { |
| 288 | // it's not allowed to create contents prefixed with 'm' since those could be mistaken for manifest contents. |
| 289 | return accessDeniedResponse() |
| 290 | } |
| 291 | |
| 292 | contentID, err := dw.ContentManager().WriteContent(ctx, gather.FromSlice(req.GetData()), content.IDPrefix(req.GetPrefix()), compression.HeaderID(req.GetCompression())) |
| 293 | if err != nil { |
| 294 | return errorResponse(err) |
| 295 | } |
| 296 | |
| 297 | return &grpcapi.SessionResponse{ |
| 298 | Response: &grpcapi.SessionResponse_WriteContent{ |
| 299 | WriteContent: &grpcapi.WriteContentResponse{ |
| 300 | ContentId: contentID.String(), |
| 301 | }, |
| 302 | }, |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | func handleFlushRequest(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, _ *grpcapi.FlushRequest) *grpcapi.SessionResponse { |
| 307 | if authz.ContentAccessLevel() < auth.AccessLevelAppend { |
no test coverage detected