I have a perspective application that contains a report. I am embedding images into this report and the perspective view from an azure blob storage container using a shared access signature.
Code that generates the signature and URL (inspiration from this post:
import base64
from java.net import URLEncoder
from datetime import datetime,timedelta
from javax.crypto import Mac
from javax.crypto.spec import SecretKeySpec
from java.util import Base64
def getStS(signedStart,signedExpiry):
signedPermissions = "r"
canonicalizedResource = "/blob/<my account>/part-images"
signedIdentifier = ""
signedIP = ""
signedProtocol = ""
signedVersion = "2024-11-04"
signedResource = "c"
signedSnapshotTime = ""
signedEncryptionScope = ""
rscc = ""
rscd = ""
rsce = ""
rscl = ""
rsct = ""
return signedPermissions \
+ "\n" + signedStart \
+ "\n" + signedExpiry \
+ "\n"+ canonicalizedResource \
+ "\n" + signedIdentifier \
+ "\n" + signedIP \
+ "\n" + signedProtocol \
+ "\n" + signedVersion \
+ "\n" + signedResource \
+ "\n" + signedSnapshotTime \
+ "\n" + signedEncryptionScope \
+ "\n" + rscc \
+ "\n" + rscd \
+ "\n" + rsce \
+ "\n" + rscl \
+ "\n" + rsct
def sign_StS(StringToSign, account_key):
key = base64.b64decode(account_key)
macObject=Mac.getInstance('HmacSHA256')
keySpec=SecretKeySpec(key,"HmacSHA256")
macObject.init(keySpec)
signature=macObject.doFinal(StringToSign.encode('utf-8'))
return signature
def getPartImage(model):
currentTime=datetime.now()
st=currentTime.strftime('%Y-%m-%dT%H:%M:%SZ')
endTime=currentTime+timedelta(seconds=30)
se=endTime.strftime('%Y-%m-%dT%H:%M:%SZ')
StringToSign=getStS(st,se)
accountKey=<MY ACCOUNT KEY>
signature=sign_StS(StringToSign,accountKey)
sig=URLEncoder.encode(Base64.getEncoder().encodeToString(signature))
return 'https://<my account>.blob.core.windows.net/part-images/'+model+'.png?sp=r&st='+st+'&se='+se+'&sv=2024-11-04&sr=c&sig='+sig
The Problem:
The perspective image component works perfectly and renders the image every time. However, in the reporting module image component, I am only able to render the image some of the time. Turns out that the times the image won’t render in the report image component, there is a %2B in the URL, which is the URL_encoded “+” character.
The url’s without that character render fine in both the perspective image component and the report image component. Is this expected behavior?

