Encryption enable public upload

This patch is based on #5976 
The changes there made it quite easy to enable the public upload feature if encryption is enabled.


To avoid merge conflicts wait with this patch until #5976 is merged!