@Test public void testRemoteURI() throws Exception { Blob blob = Blobs.createBlob(CONTENT); Binary binary = binaryManager.getBinary(blob); BlobInfo blobInfo = new BlobInfo(); blobInfo.digest = binary.getDigest(); blobInfo.length = Long.valueOf(blob.getLength()); blobInfo.filename = "caf\u00e9 corner.txt"; blobInfo.mimeType = "text/plain"; ManagedBlob mb = new SimpleManagedBlob(blobInfo ); URI uri = binaryManager.getRemoteUri(binary.getDigest(), mb, null); String string = uri.toASCIIString(); assertTrue(string, string.contains("filename*%3DUTF-8%27%27caf%C3%A9%20corner.txt")); }
@Override protected URI getRemoteUri(String digest, ManagedBlob blob, HttpServletRequest servletRequest) throws IOException { try { CloudBlockBlob blockBlobReference = container.getBlockBlobReference(digest); SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy(); policy.setPermissionsFromString("r"); Instant endDateTime = LocalDateTime.now() .plusSeconds(directDownloadExpire) .atZone(ZoneId.systemDefault()) .toInstant(); policy.setSharedAccessExpiryTime(Date.from(endDateTime)); SharedAccessBlobHeaders headers = new SharedAccessBlobHeaders(); headers.setContentDisposition(getContentDispositionHeader(blob, servletRequest)); headers.setContentType(getContentTypeHeader(blob)); String sas = blockBlobReference.generateSharedAccessSignature(policy, headers, null); CloudBlockBlob signedBlob = new CloudBlockBlob(blockBlobReference.getUri(), new StorageCredentialsSharedAccessSignature(sas)); return signedBlob.getQualifiedUri(); } catch (URISyntaxException | InvalidKeyException | StorageException e) { throw new IOException(e); } }
AzureBinaryManager extends AbstractCloudBinaryManager { @Override protected URI getRemoteUri(String digest, ManagedBlob blob, HttpServletRequest servletRequest) throws IOException { try { CloudBlockBlob blockBlobReference = container.getBlockBlobReference(digest); SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy(); policy.setPermissionsFromString("r"); Instant endDateTime = LocalDateTime.now() .plusSeconds(directDownloadExpire) .atZone(ZoneId.systemDefault()) .toInstant(); policy.setSharedAccessExpiryTime(Date.from(endDateTime)); SharedAccessBlobHeaders headers = new SharedAccessBlobHeaders(); headers.setContentDisposition(getContentDispositionHeader(blob, servletRequest)); headers.setContentType(getContentTypeHeader(blob)); String sas = blockBlobReference.generateSharedAccessSignature(policy, headers, null); CloudBlockBlob signedBlob = new CloudBlockBlob(blockBlobReference.getUri(), new StorageCredentialsSharedAccessSignature(sas)); return signedBlob.getQualifiedUri(); } catch (URISyntaxException | InvalidKeyException | StorageException e) { throw new IOException(e); } } }
AzureBinaryManager extends AbstractCloudBinaryManager { @Override protected URI getRemoteUri(String digest, ManagedBlob blob, HttpServletRequest servletRequest) throws IOException { try { CloudBlockBlob blockBlobReference = container.getBlockBlobReference(digest); SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy(); policy.setPermissionsFromString("r"); Instant endDateTime = LocalDateTime.now() .plusSeconds(directDownloadExpire) .atZone(ZoneId.systemDefault()) .toInstant(); policy.setSharedAccessExpiryTime(Date.from(endDateTime)); SharedAccessBlobHeaders headers = new SharedAccessBlobHeaders(); headers.setContentDisposition(getContentDispositionHeader(blob, servletRequest)); headers.setContentType(getContentTypeHeader(blob)); String sas = blockBlobReference.generateSharedAccessSignature(policy, headers, null); CloudBlockBlob signedBlob = new CloudBlockBlob(blockBlobReference.getUri(), new StorageCredentialsSharedAccessSignature(sas)); return signedBlob.getQualifiedUri(); } catch (URISyntaxException | InvalidKeyException | StorageException e) { throw new IOException(e); } }  }
AzureBinaryManager extends AbstractCloudBinaryManager { @Override protected URI getRemoteUri(String digest, ManagedBlob blob, HttpServletRequest servletRequest) throws IOException { try { CloudBlockBlob blockBlobReference = container.getBlockBlobReference(digest); SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy(); policy.setPermissionsFromString("r"); Instant endDateTime = LocalDateTime.now() .plusSeconds(directDownloadExpire) .atZone(ZoneId.systemDefault()) .toInstant(); policy.setSharedAccessExpiryTime(Date.from(endDateTime)); SharedAccessBlobHeaders headers = new SharedAccessBlobHeaders(); headers.setContentDisposition(getContentDispositionHeader(blob, servletRequest)); headers.setContentType(getContentTypeHeader(blob)); String sas = blockBlobReference.generateSharedAccessSignature(policy, headers, null); CloudBlockBlob signedBlob = new CloudBlockBlob(blockBlobReference.getUri(), new StorageCredentialsSharedAccessSignature(sas)); return signedBlob.getQualifiedUri(); } catch (URISyntaxException | InvalidKeyException | StorageException e) { throw new IOException(e); } }  @Override void removeBinaries(Collection<String> digests); }
AzureBinaryManager extends AbstractCloudBinaryManager { @Override protected URI getRemoteUri(String digest, ManagedBlob blob, HttpServletRequest servletRequest) throws IOException { try { CloudBlockBlob blockBlobReference = container.getBlockBlobReference(digest); SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy(); policy.setPermissionsFromString("r"); Instant endDateTime = LocalDateTime.now() .plusSeconds(directDownloadExpire) .atZone(ZoneId.systemDefault()) .toInstant(); policy.setSharedAccessExpiryTime(Date.from(endDateTime)); SharedAccessBlobHeaders headers = new SharedAccessBlobHeaders(); headers.setContentDisposition(getContentDispositionHeader(blob, servletRequest)); headers.setContentType(getContentTypeHeader(blob)); String sas = blockBlobReference.generateSharedAccessSignature(policy, headers, null); CloudBlockBlob signedBlob = new CloudBlockBlob(blockBlobReference.getUri(), new StorageCredentialsSharedAccessSignature(sas)); return signedBlob.getQualifiedUri(); } catch (URISyntaxException | InvalidKeyException | StorageException e) { throw new IOException(e); } }  @Override void removeBinaries(Collection<String> digests); static final String ENDPOINT_PROTOCOL_PROPERTY; final static String SYSTEM_PROPERTY_PREFIX; static final String ACCOUNT_NAME_PROPERTY; static final String ACCOUNT_KEY_PROPERTY; static final String CONTAINER_PROPERTY; static final String PREFIX_PROPERTY; }