def _put_many_files(self, url_files, overwrite):
    url_files = list(url_files)
    with NamedTemporaryFile(dir=self._tmpdir, mode='wb', delete=(not debug.s3client), prefix='metaflow.s3.put_inputs.') as inputfile:
        lines = (b' '.join(map(url_quote, (os.path.realpath(local), url))) for (local, url, _) in url_files)
        inputfile.write(b'\n'.join(lines))
        inputfile.flush()
        (stdout, stderr) = self._s3op_with_retries('put', filelist=inputfile.name, verbose=False, overwrite=overwrite, listing=True)
        if stderr:
            raise MetaflowS3Exception(('Uploading S3 files failed.\nFirst key: %s\nError: %s' % (url_files[0][2], stderr)))
        else:
            urls = set()
            for line in stdout.splitlines():
                (url, _, _) = map(url_unquote, line.strip(b'\n').split(b' '))
                urls.add(url)
            return [(key, url) for (_, url, key) in url_files if (url in urls)]
def _put_many_files(self, url_files, overwrite):
    url_files = list(url_files)
    with NamedTemporaryFile(dir=self._tmpdir, mode='wb', delete=(not debug.s3client), prefix='metaflow.s3.put_inputs.') as inputfile:
        lines = (b' '.join(map(url_quote, (os.path.realpath(local), url))) for (local, url, _) in url_files)
        inputfile.write(b'\n'.join(lines))
        inputfile.flush()
        (stdout, stderr) = self._s3op_with_retries('put', filelist=inputfile.name, verbose=False, overwrite=overwrite, listing=True)
        if stderr:
            raise MetaflowS3Exception(('Uploading S3 files failed.\nFirst key: %s\nError: %s' % (url_files[0][2], stderr)))
        else:
            urls = set()
            for line in stdout.splitlines():
                (url, _, _) = map(url_unquote, line.strip(b'\n').split(b' '))
                urls.add(url)
            return [(key, url) for (_, url, key) in url_files if (url in urls)]