Open zip file in automation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Open zip file in automation

L4 Transporter

Hello,

I'm downloading a zip file via API with this request:

  • response = doHttpRequest(url=zip, method='GET', headers=headers)

it's supposed that my "response" variable now it's the zip file, however when I try to open, I can't, it's like it doesn't exist. How can be unzipped and extract the .txt file inside?

3 REPLIES 3

L5 Sessionator

Hi @Josep, I dont know if that is correct. The API response might be a data stream, you will need convert it into a file first, then attempt de-compress. 

 

import requests 
r = requests.get("<URL>", stream=True)
with open("<filepath>", 'wb') as f:
   for chunk in r.iter_content(128):
       f.write(chunk)

 

L4 Transporter

Thanks for the reply,

I already tried it. However; I don't know which is the "<filepath>", where is stored the file? is it temporary?

L5 Sessionator

Hi @Josep, That was shown as an example. Try making the script work outside XSOAR with local Python installation. When you move the script to XSOAR, you will need to replace the file part with fileResult command.

  • 1529 Views
  • 3 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!