Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Added example for downloading a PDF from Google Cloud Storage #2745

Merged
merged 10 commits into from
Jul 10, 2024
16 changes: 15 additions & 1 deletion docs/user/streaming-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,18 @@ obj = s3.get_object(Body=csv_buffer.getvalue(), Bucket="my-bucket", Key="my/doc.
reader = PdfReader(BytesIO(obj["Body"].read()))
```

It works similarly for Google Cloud Storage ([example](https://stackoverflow.com/a/68403628/562769)).
To use with Google Cloud storage:

```python
from io import BytesIO

from google.cloud import storage
stefan6419846 marked this conversation as resolved.
Show resolved Hide resolved

# os.environ["GOOGLE_APPLICATION_CREDENTIALS"] must be set
stefan6419846 marked this conversation as resolved.
Show resolved Hide resolved
storage_client = storage.Client()
blob = storage_client.bucket("my-bucket").blob("mydoc.pdf")
file_stream = BytesIO()
blob.download_to_file(file_stream)
reader = PdfReader(file_stream)
```