How to compress a CSV file in Flow Designer action and then convert to base64?

User205031
Tera Contributor

Hi All,

 

I have a requirement. While submitting a catalog item, I am uploading a CSV file. I need to compress the CSV file in Flow Designer and then convert to base64.

 

How to compress the CSV file in Flow Designer?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@User205031 

you can use Zip operation from flow, create the zip file and store it on RITM or some record

then you can get base64 encoded data of that file easily

Zip operation 

Base64 encoded Attachments 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@User205031 

you can use Zip operation from flow, create the zip file and store it on RITM or some record

then you can get base64 encoded data of that file easily

Zip operation 

Base64 encoded Attachments 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

I am able to Zip the file. I have add one attachment with 44KB and after zipping it, the Zip file is now 3KB. But if I unzip it, I am again the attachment with 44KB not the compressed zip attachment which is 3KB.

 

How can I get that 3KB file and then convert this 3KB file to base64.

 

Please help!

@User205031 

your main file is 44KB, after zip it's 3KB -> till this point it's ok

If you unzip then again you will get the actual file which is 44KB -> this is also expected behavior

what's the concern?

Now that you have zip file and you have added it to some record, use this to get base64encoded data for it

Base64 encoded Attachments 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

I have stored that zip file in a record and then used it to convert it to base64.

Now I tried to check after decoding whether the contents that I am converting are correct or not, it not showing me the correct result. I could see only the file name and rest other details.

 

User205031_0-1748501306044.png

 

This Zip folder contains my Zip file. I am passing this RITM details to convert to base64. 

The zip file is inside the zip folder, but when I covert to base64, it doesnt show me correct data. 

I think it is converting the Zip folder not the file inside it.

 

Thanks!