Replies: 2 comments
-
|
Hello 👋
Agreed!
Yes. So the response from with requests.get(url, stream=True) as r:
r.raise_for_status()
for name, size, chunks in stream_unzip(r.iter_content()):
print(name)
for chunk in chunks:
print(chunk)
I think might have leave this to someone else to answer - I don't know much about Azure have to admit.
But I'll take a guess at this one. Looks like upload_blob can take an iterable as its first argument https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.blobclient?view=azure-python#azure-storage-blob-blobclient-upload-blob, and I guess it'll be an iterable of with requests.get(url, stream=True) as r:
r.raise_for_status()
for name, size, chunks in stream_unzip(r.iter_content()):
print(name)
blobclient = zipblob_service_client.get_blob_client(container, name)
blobclient.upload_blob(chunks, overwrite=True)If you do get something working - you're very welcome to raise a PR with it adding it to the documentation. stream-zip, the sister library to this one, has "recipes" https://stream-zip.docs.trade.gov.uk/recipes/ . We could have a similar concept here? |
Beta Was this translation helpful? Give feedback.
-
Actually, I'm going to give this a go too. Looks like the return value of the "chunks" function is an iterable of bytes, and so can be passed to So it's still an untested guess, but to download a zip from one blob, and upload each member to its own blob, something like: stream = source_blob_client.download_blob()
for name, size, chunks in stream_unzip(stream.chunks()):
print(name)
blobclient = zipblob_service_client.get_blob_client(container, name)
blobclient.upload_blob(chunks, overwrite=True)To re-iterate - no idea if I'm using the Azure functions correctly. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I think the project would benefit a lot from some actual examples.
Eg.:
Using request.get
Or using blobclient read to stream
Maybe i misunderstood this, but i need to download a zip from url or azure blob using python, uploading to a the blob, but i dont understand how. Can i utilze the chunkcs from requests.get stream or blobclient's own stream?
My specific example:
How would i go about updating it with stream-unzip to have the file unzipped before its written to blob
Beta Was this translation helpful? Give feedback.
All reactions