Is there a way to pipe the `hdiutil create` into a raw stream without needing to store it first? I would like to do something like
hdiutil create dest_file.dmg -srcdevice /dev/disk3 | curl -TX - PUT \
    -H &quot;Authorization: Token&quot; \
    --output /dev/null \
    &quot;https://uploadlink.com&quot;

so that I do not need to store dest_file.dmg first in order to upload (as I don't have enough diskspace for this). Is there an option to stream the file and upload using hdiutil create?
It doesn't immediately seem possible, no.
The hdiutil tool itself has no option to write to stdout.
It cannot be tricked by using /dev/fd/1 as the output file either.
Creating a named pipe using the mkfifo command doesn't work, as the hdiutil checks for the existence of the file before starting.
In this case it is possible easier for you to simply stream over the raw disk contents, and then convert it to a dmg on the receiving end (depending on which utilities you have available there). In your case it is a simple dmg file, so converting it is just a matter of adding a small footer structure to the end of the file after transferring it.
You could transfer the raw data using a command like:
dd if=/dev/rdisk3 bs=1m | curl -TX - PUT -H &quot;Authorization: Token&quot; --output /dev/null &quot;https://uploadlink.com&quot;