· Dec 31, 2019

How to save file/image at some specific folder.

Hi Team,

I want to save image/file using inter system iris web api.

I am sending file as Base64 formate  in JSON object to api .and I want to save it at D/Images folder.

please refer below code that i was tried.

Obj.OrganizationLogoBase64--> has base64 value of image

Set decode = $System.Encryption.Base64Decode(Obj.OrganizationLogoBase64)

set file = ##class(%Stream.GlobalBinary).%New()

    do file.Write(decode)

Discussion (9)2
Log in or sign up to continue

Hi Peter,

Thanks but above solution is not working.

Set Obj.OrganizationLogo="abc.png"

Set path="D:\temp\"_OrganizationLogo
    Set file=##class(%Stream.FileBinary).%New()
    Set sc=file.LinkToFile(path)
    Do file.Write(decode)
just for information
I have created web api in intersystem iris and at front end I am using angular.
So, I am passing this image as base64 formate along with the other fields like fname,lname, address etc..

in JSON 

You can just check $$$ISERR(sc) directly here, you do not need to run it through $system.Status.GetErrorText(sc)  first.

$$$ISERR(status) will compile into ('status). In the case where sc=1, status will become = "". This means that 'status will evaluate to true when sc=1, which means it will think there is an error when there is not.

USER>set sc=1
USER>set status=$system.Status.GetErrorText(sc)
USER>zw sc
USER>zw status
USER>w ('status)
USER>w ('sc)