Friday, April 30, 2021

#843 OIC for File Transfer - Rename - Move to Target - Delete Source

This is a simple scenario from a customer - they need to move files generated by their ERP to OCI Object Storage. 







There are a couple of extras -

  • Source files are on an FTP Server
  • Source file names are in the format Prefix.FileName.Suffix for example - SAP001.Mahnwesen012021.mnf
  • Customer wants the file written to object storage without prefix and suffix,
  • Customer wants files deleted from FTP Server, once they have been saved to object storage
Ok, so here's my quick demo for such - 
Files on my ftp server - 




















Here is the integration - 












































So what are the steps here?

1. ListFiles - FTP Adapter --> List File operation - this will return a list of all the files to be moved.
2. For EachFile loop - 
2.1. Read the file from FTP (pass by reference)
2.2. WriteFile to Object Storage
3. Check result of WriteFile
3.1. If success (http code = 200) -- FTP Adapter -- Delete File  

I test the integration - 

























I check the ftp directory - 

























Now to the OIC configuration details - 

ListFiles - List the files in the source directory of the ftp server -

















For Each Loop configuration - 














Read File configuration - 




















Note the dummy file name. I will set this to the name of the current file -

Map to Read File configuration - 



 




WriteFile2Storage configuration - 



















Map to Write2Storage configuration - 

first step - pass file by reference -








second step - rename - 
















I do the substring magic to extract the file name without prefix and suffix - 

concat ("https://objectstorage.us-phoenix-1.oraclecloud.com/n/tenancy/b/bucket/o/", substring-before (substring-after ($currentFile/nsmpr3:File/nsmpr3:filename, "." ), "." ) )

SWITCH - check for success configuration - 





















DeleteFile - FTP connection configuration - 




















Map to DeleteFile - same modus operandi - pass file name and directory from the currentFile variable -







No comments:

Post a Comment