Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In order to access your storage blob using SAS with Java, please follow below steps -
1. Configure the SAS access service in your Blob for your storage account. Navigate to Shared access signature setting as shown below -
2. Copy the Blob Service SAS URL. (This is required to access the blob)
3. Access your Blob in your Java code as shown in below snippet -
try {
HttpURLConnection httpClient = (HttpURLConnection) new URL(Copy Blob service SAS URL with container).openConnection();
httpClient.setRequestMethod("PUT");
httpClient.setDoOutput(true);
httpClient.setRequestProperty("x-ms-blob-type", "BlockBlob");
OutputStreamWriter out = new OutputStreamWriter(httpClient.getOutputStream());
out.write("This is test");
out.close();
httpClient.getInputStream();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Where -
storageurl = “https://<storage_account_name>.blob.core.windows.net/<container_name>/“+file.name+“sas_content“