Reputation: 13
In my app engine script (using the Python API), I'm using this code to dynamically generate zip files and serve them back to the user. When I download and extract the generated zip file and I'm running OS X, the permissions of each file extracted from the archive is 0, forcing me to chmod them. I'd rather not have my users have to do the same. Is there a way to fix this?
Upvotes: 1
Views: 167
Reputation: 101149
Yup, see the docs for the Python zipfile module. Specifically, the signature of the writestr
method, which is:
ZipFile.writestr(zinfo_or_arcname, bytes[, compress_type])
The first argument can be the filename, or a ZipInfo object, which allows you to specify information about the file to be stored. I believe the relevant field to set to change the permissions of the file is the external_attr, but some experimentation reading existing zip files may be required to determine this.
Upvotes: 1