[英]How can I split a zip file into multiple zip files of specific size and extract it as a single file in cloud storage?
我使用这个 function 将 zip 文件提取到云存储桶中。
def zipextract(self, zipfilename_with_path, subfile):
"""Unzip file into Cloud Storage."""
bucket = self.storage_client.get_bucket(self.bucketname)
bucket_dest = self.storage_client.get_bucket(self.project_id)
blob = bucket.blob(zipfilename_with_path)
if blob.exists():
zipbytes = io.BytesIO(blob.download_as_string())
if is_zipfile(zipbytes):
with ZipFile(zipbytes, 'r') as myzip:
for contentfilename in myzip.namelist():
contentfile = myzip.read(contentfilename)
blob = bucket_dest.blob(
subfile + "/" + contentfilename)
blob.upload_from_string(contentfile)
如何将 zip 文件(解压前)拆分为多个特定大小的 zip 文件并将其作为单个文件提取到云存储中?
您可以创建多部分 zip,但您既不能单独解压缩该部分,也不能在创建存档后拆分它(您必须在存档创建期间指定该部分)。
在您的上下文中,我不理解具有相同 zip 的多个部分的值,因为您必须获得所有部分才能正确解压缩文件并验证 CRC。
如果您想要几个可以单独解压缩的部分,则必须在压缩之前拆分文件,分别压缩每个部分,然后您将能够使用有效的 CRC 单独解压缩。 但同样,我没有抓住目标,因为你想在最后合并所有部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.