Business Operation to Integrate with Amazon S3 , How to send File to Amazon S3 using HTTP Outbound

Primary tabs

Hi All,

I created a Business Operation to Integrate with Amazon S3.
I have used HTTP Outbound Adapter for the same. Used Get method of Adapter Class.
Basically in a request I want to send Unique File Name and File and in Response I want to get Version ID and if operation was successful, then set flag to true.

I have created a class for request in that I have two properties, as shown Below :
   

    Property fileName As %String;
    Property file As %GlobalBinaryStream;

This is in my Operation Class
 

            set pResponse = ##Class(SaveFileResponse).%New()
            set fileName = pRequest.fileName
            set file = pRequest.file

            set tSC = ..Adapter.Get(.HttpResponse,"filename",fileName)
            if (HttpResponse.StatusCode = 200) {
                set pResponse.fileSaved = 1
                set pResponse.fileVersionID = HttpResponse.ContentInfo
            }
            else {
                set pResponse.fileSaved = 0
            }

I have also created Business Operation in Production and configured URL and HTTP Configuration and SSL Configuration in Settings for the same.

Is this all correct ? Is my approch okay ?

Kindly help me on this . 

  • 0
  • 0
  • 90
  • 6
  • 0

Comments

Also , How can I create a Business Service which can call this Business operation from Code Itself.  How can I do this ?

Thanks @Suman Samanta,

In my BO XData MessageMap was missing somehow.

I added that now I am able to see that Request Class under TEST.

But Still in Test Screen, I am getting onle one property of my class visible.
it is not having filed to choose a  File to be send to S3.
What should I do next ?

Click "Visual Trace" link to view details.

In your case there's 403 error, so you're not authenticated.

Check this topic for AWS authorization options.

Thanks @Eduard Lebedyuk , Actually that my mistake I missed XDATA Mapping.

But I was successfully able to connect to Amazon with Operation and as a Service I was using Enslib.File.PassThrough Service.
But in this approch I will have to store file at a location and fetrch from that for sending to operation.

But I dont want to store files in any filepath rather want to just direct pass a file coming as a request in Service and calling Operation .

I am unable to do that , How can I achieve this ?

Actually I tried to pass the file to Business Service and it is coming up in BS but when I call BO and pass the file as Input, in BO File is Blank. 

Use %Stream.GlobalBinary to pass streams without saving them on disk. Also use Ens.StreamContainer as an interoperability message class.

If you used %Stream.TmpBinary class to hold your stream, it would not be saved.

Thanks @ Eduard Lebedyuk , It worked I guess, the way I wanted.
Thank You so much, I just changed the Property of Request class from %BinaryStream to %Stream.Global Binary as You advised.

Also in Business Operation I used Ens.StreamContainer and it worked.