Goal1 : Describe the different steps for connecting Magic xpi with Amazon S3 using a DotNet custom component
Goal2 : Describe general steps to develop a custom component
Prerequisite : Access to Amazon S3 with AccessKey, SecretKey, Region and Endpoint URL.
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_11-1024x448.png)
Check with postman that you can have access to Amazon service
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_1_-1024x603.png)
1/ Copy the custom component for Amazon S3 (AmazonS3) to the <Magic xpi installation directory>\Runtime\addon_connectors
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_2.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_3-1024x226.png)
2/ Open the Magic xpi Studio, you should see the Connector AmazonS3 in the Toolbox repository
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_4-1-1024x787.png)
3/ Open the Magic xpi Resources repository and create an AmazonS3 resource
Set the credentials with the amazon S3 related informations
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_5-1-1024x531.png)
Click Validate, you should see a successfull message displaying the number of buckets
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_6-1-1024x476.png)
4/ Drag and Drop the AmazonS3 connector and right click to configure it
Catch the Store Result In in a Blob variable and press OK
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_7-1-1024x636.png)
5/ If you want to list Objects in a Bucket, choose the Method “ListingObjects” and set the Region and the BucketName
!! For each method, you have to set all fields with a value (for empty value just enter 2 simple quotes)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_8-1-1024x585.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_22.png)
6/ Run the Flow in Debug Mode and check the result in the C.UserBlob variable.
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_9-1-1024x418.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_10-1024x818.png)
The response should be an Array of Amazons3Response including attributes of each object.
7/ The connector implements 8 methods (putfile, getobject, ListingObjects, DeleteObjects, uploadDirectory, downloadDirectory, CreateBucket, DeleteBucket)
8/ Next, i will describe the major steps to follow in other to create the connector.
You have to develop 2 projects one for the UI used in design mode and one for the Runtime. I’ll use Dotnet technology for both of them.
(*) you can use java for the runtime project.
9/ Open The connector Builder and create all the informations to create the connector skeleton.
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_12.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_13.png)
10/ Open the UI project with Visual Studio and load these assemblies
<Magic xpi installation>\Studio\Extensions\Application (iBolt.Common.dll, MagicSoftware.Integration.UserComponents.dll) and <Magic xpi installation>\Runtime (XPI_SDK.dll)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_14.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_15.png)
11/ The “ValidateResource” method is called when you click on the Validate Button in the resource repository
ResourceData is used to retrieve credentials from the resource repo.
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_16-1024x481.png)
Create an instance of the Amazons3 client, list the number of buckets and display a successfull message if it’s ok.
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_17-1024x371.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_18-1024x499.png)
12/ Design the connector configuration screen.
The method “Configure” is called when you right click on the connector. You have to use an MVVM model and use XAML to design the screen
You should used a Class that implements a Magic xpi UserControl
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_19-1.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_20-1-1024x740.png)
In the code behind, you have to use the methods below
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_20_bis-1024x624.png)
13/ In design Mode, when you click OK on the connector, the “GetXMLSchemaConfiguration()” is called from “GetSchema()” and then the xsd file opens in the mapper
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_21-1-1024x673.png)
14/ Build the solution and copy all files (dll, …) in the <Magic xpi installation dir>\Runtime\addon_connectors\AmazonS3\ui\lib
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_23.png)
15/ Now Open the Runtime Project with Visual Studio
In Runtime mode, “invoke” method is called. Payload is retrieved from the variable StepParams.PayloadOBject and the resource from StepParams.ResourceObject.TryGetValue
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_24-1024x709.png)
Define 2 variables to catch the response and the success indication (variables “operationSuccess” and “operationSuccessAmazonS3” are retrieved from StepData Class declared in the UI project)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/image-1024x279.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_26.png)
16/ According to the received payload, call to right method from S3Client class and pass the payload and aws credentials.
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/image-1-1024x386.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_28-1024x690.png)
17/ Serialize in XML the response
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_29.png)
18/ Rebuild the solution and copy the related files into <Magic xpi directory>\Runtime\addon_connectors\AmazonS3\runtime\dotnet\lib
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/07/AWS_S3_30-1024x461.png)
19/ The Connector and source file is available here (for Magic xpi 4.14) : https://france.magicsoftware.com/share/amazons3.zip
20/ Documentation (Magic xpi Connector Builder.pdf and AWS SDK for .NET V3 API Documentation (amazon.com))