Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Lib
cloud
azure
OS Core Lib Azure
Commits
d20150ec
Commit
d20150ec
authored
Nov 17, 2020
by
Krishna Nikhil Vedurumudi
Browse files
Explicit method to generate a PreSigned URL along with SAS Token
parent
ef16757b
Pipeline
#15839
passed with stages
in 14 minutes and 3 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
d20150ec
...
...
@@ -20,7 +20,7 @@
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
core-lib-azure
</artifactId>
<packaging>
jar
</packaging>
<version>
0.0.4
2
</version>
<version>
0.0.4
3
</version>
<name>
core-lib-azure
</name>
<properties>
...
...
src/main/java/org/opengroup/osdu/azure/blobstorage/BlobStore.java
View file @
d20150ec
...
...
@@ -169,6 +169,31 @@ public class BlobStore {
public
String
getSasToken
(
final
String
dataPartitionId
,
final
String
filePath
,
final
String
containerName
,
final
OffsetDateTime
expiryTime
,
final
BlobSasPermission
permissions
)
{
BlobContainerClient
blobContainerClient
=
getBlobContainerClient
(
dataPartitionId
,
containerName
);
BlockBlobClient
blockBlobClient
=
blobContainerClient
.
getBlobClient
(
filePath
).
getBlockBlobClient
();
return
generateSASToken
(
blockBlobClient
,
expiryTime
,
permissions
);
}
/**
* @param dataPartitionId Data partition id
* @param filePath Path of file (blob) for which SAS token needs to be generated
* @param containerName Name of the storage container
* @param expiryTime Time after which the token expires
* @param permissions Permissions for the given blob
* @return Generates Pre-Signed URL for a given blob.
*/
public
String
generatePreSignedURL
(
final
String
dataPartitionId
,
final
String
filePath
,
final
String
containerName
,
final
OffsetDateTime
expiryTime
,
final
BlobSasPermission
permissions
)
{
BlobContainerClient
blobContainerClient
=
getBlobContainerClient
(
dataPartitionId
,
containerName
);
BlockBlobClient
blockBlobClient
=
blobContainerClient
.
getBlobClient
(
filePath
).
getBlockBlobClient
();
return
blockBlobClient
.
getBlobUrl
()
+
"?"
+
generateSASToken
(
blockBlobClient
,
expiryTime
,
permissions
);
}
/**
*
* @param blockBlobClient Blob client
* @param expiryTime Time after which SAS Token expires
* @param permissions Permissions for the given blob
* @return Generates SAS Token.
*/
private
String
generateSASToken
(
final
BlockBlobClient
blockBlobClient
,
final
OffsetDateTime
expiryTime
,
final
BlobSasPermission
permissions
)
{
BlobServiceSasSignatureValues
blobServiceSasSignatureValues
=
new
BlobServiceSasSignatureValues
(
expiryTime
,
permissions
);
return
blockBlobClient
.
generateSas
(
blobServiceSasSignatureValues
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment