Skip to content

Commit

Permalink
DOC: Added example for downloading a PDF from Google Cloud Storage (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
prodeveloper authored Jul 10, 2024
1 parent 6ef6d7e commit 8e02580
Showing 1 changed file with 15 additions and 1 deletion.
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

# os.environ["GOOGLE_APPLICATION_CREDENTIALS"] must be set
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)
```

0 comments on commit 8e02580

Please sign in to comment.