简体   繁体   English

使用身份验证读取存储在服务器上的远程Excel文件

[英]read remote excel file stored on a server with authenticaion

I need to access a remote excel file https://wim-example.com/rest/api/2/issue/SDLCDEVOPS-3238/abc.xlsx that is attached to a JIRA ticket. 我需要访问附加在JIRA票证上的远程Excel文件https://wim-example.com/rest/api/2/issue/SDLCDEVOPS-3238/abc.xlsx Each time I access JIRA ticket I have to add authentication token to the connection. 每次访问JIRA票证时,我都必须向连接添加身份验证令牌。 I have to use the XSSFWorkbook that takes inputstream 我必须使用需要输入流的XSSFWorkbook

URLConnection con1 = url1.openConnection(); con1.setRequestProperty("Authorization", "Basic dTU3NjI3MjpGcmVtb250MTIz");

How can I get the input stream that I can give to XSSFWorkbook? 如何获得可以提供给XSSFWorkbook的输入流?

Figured out how to provide the inputstream: 弄清楚如何提供输入流:

Connection. 连接。 getInputStream() 的getInputStream()

URLConnection con1 = url1.openConnection();
con1.setRequestProperty("Authorization", "Basic dTU3NjI3MjpGcmVtb250MTIz");

XSSFWorkbook fs = new XSSFWorkbook(con1.getInputStream());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM