Technical Articles
Cloud Integration with Commerce Azure Blob Storage using Open Connectors
Introduction:
This blog post is to showcase the capability of Azure Blob Open Connector.
Scenario:
Transfer a ZIP file from FTP server to Commerce Azure Blob storage.
Prerequisite Setup:
Set up an Integration suite trial. Help Link: Setup.
Instance Creation in Open Connectors:
Connector Instance
Design Solution in Cloud Integration:
Integration Flow
Step 1:
Configure FTP sender channel to pick a zip file from the FTP server.
Step 2:
Use Content Modifier to set properties as shown below.
Content Modifier
‘credentialAlias’ refers to the user credentials of type Open Connectors.
Security Material
Step 3-4:
Construct multipart and set authorization header using Groovy Script.
import com.sap.gateway.ip.core.customdev.util.Message
import javax.activation.DataHandler
import javax.mail.internet.ContentType
import javax.mail.internet.MimeBodyPart
import javax.mail.internet.MimeMultipart
import javax.mail.util.ByteArrayDataSource
import com.sap.it.api.ITApiFactory
import com.sap.it.api.securestore.SecureStoreService
import com.sap.it.api.securestore.UserCredential
import com.sap.it.api.securestore.exception.SecureStoreException
def Message constructMultipart(Message message) {
byte[] bytes = message.getBody(byte[])
MimeBodyPart bodyPart = new MimeBodyPart()
ByteArrayDataSource dataSource = new ByteArrayDataSource(bytes, 'application/zip')
DataHandler byteDataHandler = new DataHandler(dataSource)
bodyPart.setDataHandler(byteDataHandler)
String fileName = message.getHeaders().get("CamelFileName")
bodyPart.setFileName(fileName)
String fileType = message.getProperties().get("fileType")
bodyPart.setDisposition('form-data; name="file"')
bodyPart.setHeader("Content-Type",fileType)
MimeMultipart multipart = new MimeMultipart()
multipart.addBodyPart(bodyPart)
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()
multipart.writeTo(outputStream)
message.setBody(outputStream)
String boundary = (new ContentType(multipart.contentType)).getParameter('boundary')
message.setHeader('Content-Type', "multipart/form-data; boundary=${boundary}")
return message
}
def Message setAuthHeader(Message message) {
def credentialAlias = message.getProperty("credentialAlias")
def secureStorageService = ITApiFactory.getService(SecureStoreService.class, null)
def credential = secureStorageService.getUserCredential(credentialAlias)
def pwd = credential.getPassword()
message.setHeader("Authorization",pwd)
return message
}
I have re-used the code for multipart creation from here (solution provided by Eng Swee Yeoh).
Step 5:
Configure HTTP receiver channel as shown below.
HTTP Receiver Adapter
TakeAway Points:
- Instead of Open Connectors receiver adapter, HTTP receiver adapter is used because of the some unsupported features mentioned in the SAP Note
- Open connector instance expects the file in form-data format.
- Container name and path should be passed as query parameters while posting data to open connector.
Thank you for reading this blog post. Please feel free to share your feedback or thoughts or ask questions in the Q&A tag below.
Regards,
Priyanka Chakraborti
Priyanka Chakraborti
2. Now open connectors adapter supports below or still to use https adapter ?
3. how secured to expose Integration suite paas to external apps via Azure blob for inbound case?
Priyanka Chakraborti
Open connector instance accepts only multi form data by default when integrating BTP Integration Suite with Azure Blob ? Do we have any alternatives ? .
when Container name and path should be passed as query parameters while posting data to open connector instance then there will be HTTP usage since multiple query isn't supported by open connector adapter ?