Skip to main content

Hi Zapier Community!

Im trying to use a ZIP File that is passing trough a sub-zap and when it goes into th sub-zap looks like: 

 https://zapier.com/engine/hydrate/16299789/.eJxNkduSmkAUR...

 

Then trying to encode in Base64 to pass trough a AWS Lambda Function,  im using this code:

import base64
import urllib

result = l]
data = urllib.request.urlopen(input_data_'zip_file'])
zip_file = open(data.read(),'rb')
bs64 = base64.b64encode(zip_file.read())
return t{'lines': bs64 }]

But i seems it’s parsing bad the zipfile, get a lot of errors:

 

Your code had an error! Traceback (most recent call last): File "<string>", line 13, in the_function ValueError: embedded null byte

 

How can i do this??

I solved this.

import base64
import urllib.request

zip_url = input_data['zip_file']
with urllib.request.urlopen(zip_url) as response:
zip_file_content = response.read()
bs64 = base64.b64encode(zip_file_content).decode('utf-8')

return [{'base64_zip': bs64}]

Cheers!


Reply