For those who reach this out, %FileCharacterStream class was deprecated in favor of %Stream.FileCharacter. Here is the updated snippet for convinence:
Set tTempFile = ##class(%Stream.FileCharacter).%New()
Set tTempFile.Filename = "/tmp/file.csv"
$$$THROWONERROR(st, tTempFile.CopyFrom(csvfile))
$$$THROWONERROR(st, tTempFile.%Save())
Hi Prashanth,
I had a similar requirement once. The following is how I managed it:
First, I setup a method in a CSP dispatch class, which respond to a REST endpoint, to invoke a Business Service in the current namespace working production:
ClassMethod SomeRestEndpointCallback(body As %DynamicArray) As %DynamicObject
{
$$$TOE(st, ##class(Ens.Director).CreateBusinessService("BusinessServiceName", .service))
$$$ThrowOnError(service.ProcessInput(body, .output))
Return output
}
Then, I created a adapterless Business Service (https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...) in order to don't pooling for data but just wait for an external trigger instead:
Class some.package.AdapterlessBS Extends Ens.BusinessService
{
/// Configuration item(s) to which to send file stream messages
Property TargetConfigNames As Ens.DataType.ConfigName(MAXLEN = 1000);
Parameter SETTINGS = "TargetConfigNames:Basic:selector?multiSelect=1&context={Ens.ContextSearch/ProductionItems?targets=1&productionName=@productionId}";
Method OnProcessInput(request As %RegisteredObject, Output response As %RegisteredObject) As %Status
{
Set tSC = $$$OK
Try {
// Could be any message... adapter to your needs
Set tMsg = ##class(Ens.StringResponse).%New()
Set tMsg.StringValue = "some value"
// Send the message to the targets
Set targets = $LFS(..TargetConfigNames)
For i=1:1:$LL(targets) {
Set target = $LG(targets, i)
// can be sync or async... it's up to you decide
//Set tSC = ..SendRequestSync(target, tMsg)
Set tSC = ..SendRequestAsync(target, tMsg)
Quit:$$$ISERR(tSC)
}
}
Catch (ex) {
Set tSC = ex.AsStatus()
}
Quit tSC
}
Now, you can add this Business Service to a interoperability production and set the desired Business Process as its target. So, when your REST endpoint is accessed, it will call the BS and then the BP.
HTH,
José
![Popular writer](https://community.intersystems.com/sites/default/files/badges/poular_writer.png)
![Notable writer](https://community.intersystems.com/sites/default/files/badges/303371140-d391d770-6fa4-4540-a8d5-926f8dfe9f61.png)
![Blogger Badge](https://community.intersystems.com/sites/default/files/badges/blogger_badge_0.png)
![Reporter Badge](https://community.intersystems.com/sites/default/files/badges/reporter_badge_0.png)
![Influencer Badge](https://community.intersystems.com/sites/default/files/badges/influencer_badge.png)
![Curious Member](https://community.intersystems.com/sites/default/files/badges/curious_member_badge.png)
![Insightful Author](https://community.intersystems.com/sites/default/files/badges/297760167-e550c050-8b02-41e7-a41a-e482b4bad66f.png)
I'm also interested, @Olga Zavrazhnova :)