Very unclear what this should mean:
However, not understanding what that means, my 2 cents on a possibly different approach.
@fatimamahmood717 in order to avoid to fight with all that file-like memory-stream code, why not just save the zip file in Anvil’s-server-environment /tmp folder, use it, then delete it?
Have you checked this secion of the docs where it’s explained how save a MediaObject to disk?
def write_a_media_object():
media_object = anvil.BlobMedia('text/plain', b'Hello, world', name='hello_world.txt')
with open('/tmp/hello_world.txt', 'wb+') as f:
# Write the byte contents of the media object to 'tmp/my-file.txt'
# (we opened the file in binary mode, so f.write() accepts bytes)
f.write(media_object.get_bytes())
This way may be you find yourself in a more familiar local-pc-like environment and managing a filesystem-hosted zip file might result more straightforward.
Just keep in mind this:
Read and write files as normal
You can also use Python’s open
to read and write files as normal. Your filesystem is your own; other users do not have access to it.
Files in your filesystem are temporary, and may be removed without warning. We advise you only to access files in the /tmp
directory.
BR