A few have complained that there is a bug with this, but you can not directly transfer raw materials in space. Inorder to transfer you need do either have a smaller ship to dock with both and transfer that way or dock with a space station.

To transfer to a space station a capital or frieghter just needs to be in the same square as they use the docking ports.