added support to save a file in a temporary folder until file is completely downloaded