Enhance bulk publish to support raw byte array payload #1646
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request enhances the bulk publishing feature to natively support raw byte[] payloads through the generic BulkPublishEventAsync method. This provides a unified and efficient way for developers to publish both structured (JSON) and raw binary data in a single bulk operation.
Issue reference
When an event is a byte[], it is now correctly handled as raw binary data. The Content-Type is set to application/octet-stream, and the payload is sent directly, bypassing JSON serialization. For all other event types, the existing behavior of serializing the payload to JSON is preserved. Added Unit Test: A new test case, BulkPublishEventAsync_CanPublishTopicWithByteArrayEvents, has been added to BulkPublishEventApiTest.cs. This test validates that calling BulkPublishEventAsync with a List<byte[]> correctly constructs the gRPC request with the application/octet-stream content type and ensures the byte payloads are sent unmodified.
Please reference the issue this PR will close: #[issue number]
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: