通过 url telegram-api 发送文件

Send file by url telegram-api

如何设置我通过 url 在电报中发送的文件的名称?

new SendDocument()
                .setChatId(message.getChatId())
                .setDocument("https://www.okbhmao.ru/download.php?file=12021");

我想用名字 contract.pdf

在电报聊天中发送这个文件

我是这样解决的:

new SendDocument()
                  .setChatId(message.getChatId())
                  .setDocument("contract.pdf", new URL("https://www.okbhmao.ru/download.php?file=12021").openStream());