def write(self, data):
        # Won't work on windows because you can't open file second time without
        # closing it
        with NamedTemporaryFile() as temp:
            temp.write(data)
            temp.flush()
            temp.seek(0)
            formatted_args = [arg.format(filename=temp.name) for arg in self.put_args]
            returncode, stdout, stderr = self._call_binary(
                [self.put_binary] + formatted_args
            )

            if returncode != 0:
                raise error.Abort(
                    "Infinitepush failed to upload bundle to external store: %s"
                    % stderr
                )
            stdout_lines = stdout.splitlines()
            if len(stdout_lines) == 1:
                return stdout_lines[0]
            else:
                raise error.Abort(
                    "Infinitepush received bad output from %s: %s"
                    % (self.put_binary, stdout)
                )