Creating zip file from byte
<p>I'm sending byte string of a zip file from client side using <code>JSZip</code> and need to convert it back to zip on server side. the code I've tried isn't working.</p>

<pre><code>b = bytearray()
b.extend(map(ord, request.POST.get("zipFile")))

zipPath = 'uploadFile' + str(uuid.uuid4()) + '.zip'
myzip = zipfile.ZipFile(zipPath, 'w') 
with  myzip:
    myzip.write(b)
</code></pre>

<p>It gives the error:</p>

<pre><code>stat: path too long for Windows 
</code></pre>

<p>How do I save my byte string as a zip file?</p>

<p>Haven't tried it, but you could  use <a href="https://docs.python.org/3/library/io.html#buffered-streams" rel="nofollow"><code>io.BytesIO</code></a> to construct a Buffered Stream
with your bytes and then create your zip file like so:</p>

<pre><code>import io

with ZipFile('my_file.zip', 'w') as myzip:
    myzip.write(io.BytesIO(b))
</code></pre>

python python-3.x zipfile