Zipping the .Txt Files

Avatar

Avatar
Validate 1
Level 1
ramang22522684
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
ramang22522684
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
ramang22522684
Level 1

08-11-2017

Hi Team,

I am trying to zip a .txt file using below code:

var w = vars.filename;              //file path + file name:

zip.save(w + ".zip", true);         this is where the zipped file will be saved. You must include the zipped file name including .zip file extension

Above code is working fine on our dev instance where source and target are locally hosted . but the same code is giving issue on UAT instance as source and target are remotely hosted.

Then we used the below code on UAT instance , that is able to generate zip file but multiple folder are getting created under zip file.

execCommand("zip '" + w + "'.zip '" + w + "'");  (in place of zip.save(w + ".zip", true);)

So anyone can help me with some another set of code or any suggestion on this.

Regards

Raman

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 1
ramang22522684
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
ramang22522684
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
ramang22522684
Level 1

08-11-2017

Thanks buddy for the response.

But I have tried all the possible combinations with w and y variables.

var w = vars.filename;

execCommand("zip '" + w + "'.zip '" + "/" + y + "'");

execCommand("zip '" + w + "'.zip '" + "/" + w + "'");

execCommand("zip '" + y + "'.zip '" + "/" + w + "'");

execCommand("zip '" + y + "'.zip '" + "/" + y + "'");

In the above command "y" represent the the filename only)

We checked the folder where we are trying to place the zip file but its not there.

var w = vars.filename;              //file path + file name: /usr/local/neolane/outgoing/TEST_ABCI_00000100_20171025193028.txt

var x = w.split("/");

var y = x[5];                       //fileName: TEST_ABCI_00000100_20171025193028.txt

So it would be helpful if we can have some another set of code for zipping the files or updates in this command.Amit KumarAdhiyan​, Could you guys please have a look over my issue and help me out.

Avatar

Avatar
Contributor
Level 3
saikatk2447661
Level 3

Likes

22 likes

Total Posts

58 posts

Correct reply

14 solutions
Top badges earned
Contributor
Shape 1
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Contributor
Level 3
saikatk2447661
Level 3

Likes

22 likes

Total Posts

58 posts

Correct reply

14 solutions
Top badges earned
Contributor
Shape 1
Give Back 5
Give Back 3
Give Back
View profile
saikatk2447661
Level 3

08-11-2017

var w = vars.filename;

In case of execCommand, if the filename contains the absolute path (i.e. /home/somefolder/file.txt) then same folder hierarchy will be created inside zip file. Modify the w variable to get only file name.