Refactor file sharing public link handling

fixes download issue introduced by #10755

a