@@ -239,6 +239,48 @@ Invoke-RestMethod -Method Post -ContentType 'application/cloudevents+json' -Body
239239
240240{{< /tabpane >}}
241241
242+ ### Publish binary CloudEvents
243+
244+ In binary mode, the transport payload only contains the event body, while
245+ CloudEvent attributes are supplied via transport metadata that begins with the
246+ ` ce_ ` prefix (HTTP headers, Kafka headers, NATS headers, and so on). This is
247+ useful when you already produce binary mode events or you want to send arbitrary
248+ binary data without wrapping it in an additional JSON envelope.
249+
250+ To publish a binary CloudEvent to Dapr (via HTTP/gRPC publish APIs or directly
251+ into a broker that Dapr reads from):
252+
253+ 1 . Set the transport’s native content-type metadata (for example the HTTP
254+ ` Content-Type ` header or a Kafka ` content-type ` message header) to the MIME
255+ type that represents binary data, which is ` application/octet-stream ` .
256+
257+ 2 . Add the required CloudEvent attributes (` ce_specversion ` , ` ce_type ` ,
258+ ` ce_source ` , ` ce_id ` ) as transport metadata. Optional attributes such as
259+ ` ce_subject ` , ` ce_time ` , or ` ce_traceparent ` are also honored.
260+
261+ 3 . Send the payload bytes in the message body.
262+
263+ {{< tabpane text=true >}}
264+
265+ {{% tab "HTTP API (Bash)" %}}
266+
267+ Publish a Binary CloudEvent to orders topic:
268+
269+ ``` bash
270+ curl -X POST http://localhost:3500/v1.0/publish/order-pub-sub/orders \
271+ -H " Content-Type: application/octet-stream" \
272+ -H " ce_specversion: 1.0" \
273+ -H " ce_type: com.example.order.created" \
274+ -H " ce_source: urn:example:/checkout" \
275+ -H " ce_id: 2a8bbf52-1222-4c2c-85f0-8a8875c7bc10" \
276+ -H " ce_subject: orders/100" \
277+ --data-binary $' \x01\x02\x03\x04 '
278+ ```
279+
280+ {{% /tab %}}
281+
282+ {{< /tabpane >}}
283+
242284## Event deduplication
243285
244286When using cloud events created by Dapr, the envelope contains an ` id ` field which can be used by the app to perform message deduplication. Dapr does not handle deduplication automatically. Dapr supports using message brokers that natively enable message deduplication.
0 commit comments