英文:
How to read file from Azure SAS using Java
问题
我在Azure Blob Storage中有一个CSV文件的SAS URL。我需要下载该文件并将其写入SQL数据库。问题是,如何使用SAS URL下载文件。我尝试过使用`RestTemplate`,但是出现了`NullPointerException`。由于我对Java不太熟悉,无法解决这个问题。
String url = "https://orcatest.blob.core.windows.net/ABC/extract.csv?st=2020-04-";
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM));
HttpEntity<String> entity = new HttpEntity<String>(headers);
ResponseEntity<String[]> response = restTemplate.exchange(link, HttpMethod.GET, entity, String[].class);
英文:
I have SAS URL of CSV file in Azure Bolb Storage. I need to download the file and write it to a SQL database. The question is, how to download the file using SAS URL. I tried with RestTemplate
, but I'm getting a NullPointerException
. Since I'm new to Java I can't figure this out.
String url="https://orcatest.blob.core.windows.net/ABC/extract.csv?st=2020-04-";
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM));
HttpEntity<String> entity = new HttpEntity<String>(headers);
ResponseEntity<String[]> response = restTemplate.exchange(link, HttpMethod.GET, entity, String[].class);
专注分享java语言的经验与见解,让所有开发者获益!
评论