def handle_transfer(self, path, type, name=None, contents=None):
        action = self.__action_for_transfer(path, type, contents)

        if action.staging_needed:
            local_action = action.staging_action_local
            if local_action:
                response = self.client.put_file(path, type, name=name, contents=contents, action_type=action.action_type)

                def get_path():
                    return response['path']
            else:
                job_directory = self.client.job_directory
                assert job_directory, "job directory required for action %s" % action
                if not name:
                    name = basename(path)
                self.__add_remote_staging_input(action, name, type)

                def get_path():
                    return job_directory.calculate_path(name, type)
            register = self.rewrite_paths or type == 'tool'  # Even if inputs not rewritten, tool must be.
            if register:
                self.register_rewrite(path, get_path(), type, force=True)
        elif self.rewrite_paths:
            path_rewrite = action.path_rewrite(self.path_helper)
            if path_rewrite:
                self.register_rewrite(path, path_rewrite, type, force=True)

        # else: # No action for this file
dataset/ETHPy150Open galaxyproject/pulsar/pulsar/client/staging/up.py/TransferTracker.handle_transfer/original