Skip to main content
Question

Cannot Rename Files in SFTP dst Server

  • August 28, 2022
  • 6 replies
  • 157 views

  • Opening Band
  • 19 replies

Hello , 


I have a simple pipeline where i want some csv files to be moved from s3 bucket to SFTP server,
However the files saved in the SFTP server should have different naming that includes the current date, something like:
“mer_YYYYMMDDHHmmss.csv”

i tried in the file name expression field in the sftp server destination to come up with expression evaluating the above but it always produces errors that functions like YYYY() is not a function.

6 replies

saleempothiwala
Headliner
Forum|alt.badge.img
  • Headliner
  • 258 replies
  • August 28, 2022

@N_ali 

Use expression language to create a new file name. Something like

${str:concat(record:value('/fileInfo/filename'), ".json")}

Instead of “.json”, you can add something like ${YYYY()-MM()-DD()} 

More information here

 


  • Author
  • Opening Band
  • 19 replies
  • August 28, 2022

whenever i use YYYY() or MM() or any other date function

i get this error : Error evaluating expression ${YYYY()-MM()-DD()}: javax.servlet.jsp.el.ELException: No function is mapped to the name "YYYY" .

 


  • Author
  • Opening Band
  • 19 replies
  • August 28, 2022

i have the files in amazon S3 bucket as mer-timestamp-version.csv , for example mer-123654789-1.csv
i want them to be saved in SFTP server as mer_YYYYMMDDhhmmss.csv , for example mer_20220828085700.csv


saleempothiwala
Headliner
Forum|alt.badge.img
  • Headliner
  • 258 replies
  • August 28, 2022

@N_ali Ah ok…

Try using an expression evaluator. If 123456789 in  mer-123654789-1.csv is the timestamp then try creating the file name in an expression evaluator…

get the number bit in another variable called mytimestamp

create a new field called /myfilename as concatenate of 
record:value('/fileInfo/filename') + time:millisecondsToDateTime(<long>)


  • Author
  • Opening Band
  • 19 replies
  • August 29, 2022

can you please provide me with an example ,
i am having hard time creating the expression without errors.


  • Author
  • Opening Band
  • 19 replies
  • August 31, 2022

i managed to get the timestamp and convert it into a datetime but it’s displayed as Aug 27 8:30 AM for example but i want it like 20220827083000 where this evaluates to YYYYMMDDHHmmss

 

Appreciating your response on this.