Fix share download

fixes download issue introduced by https://github.com/owncloud/core/pull/10755

This is a fairly large change please test thoroughly as im sure we missed some cases

<hr/>

Other regressions also found on master:

- [x] Sharing a album in the gallery does not produce a link to the public gallery sharing

<hr/>

Bugs in this PR:

- [x] share a text file and try to download it from the public link -> text file will contain the string "null" at the end. (reported by @schiesbn)