Now releasing session lock before streaming the file to prevent session deadlock in the event of a cancelled upload.
Changed file link insertion code to reuse existing link creation code.