How to Convert Image located on remote location to base64 from image url
I want to convert the image to base64.
I have only a remote image URL.
please suggest the solution with allow cors origin.
Product version: IRIS 2020.1
Discussion (1)0
Comments
1. 通过%NetRequest类获得图片
2. 通过下面方法得到图片的Base64流
ClassMethod Img2Base64(imgDataStream) As %Stream.GlobalCharacter{
Set sgc = ##class(%Stream.GlobalCharacter).%New()
set byteList = imgDataStream.Read(12288)
while(byteList'=""){
set baseStr = ##class(%SYSTEM.Encryption).Base64Encode(byteList)do sgc.Write(baseStr)
set byteList = ""
set byteList = img.Read(12288)
}
do imgDataStream.%Close()
set imgDataStream=""
quit sgc}