Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
PriyankaChak
Active Contributor

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 engswee.yeoh).

Step 5:


Configure HTTP receiver channel as shown below.


HTTP Receiver Adapter



TakeAway Points:



  1. Instead of Open Connectors receiver adapter, HTTP receiver adapter is used because of the some unsupported features mentioned in the SAP Note

  2. Open connector instance expects the file in form-data format.

  3. 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.

QA link

Regards,

Priyanka Chakraborti
2 Comments
Labels in this area