Skip to content

Commit 8b5eda4

Browse files
author
Richard O'Dwyer
committed
adds drive_download_contents() method to client
1 parent 01d1e6f commit 8b5eda4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ refresh_session = client.drive_refresh_session(item_id)
183183
close_session = client.drive_close_session(item_id)
184184
```
185185

186+
#### Download the contents of a specific item
187+
```
188+
contents_bytes = client.drive_download_contents(item_id)
189+
```
190+
186191
#### Get worksheets
187192
```
188193
get_worksheets = client.excel_get_worksheets(item_id)
@@ -254,4 +259,4 @@ update_range = client.excel_update_range(item_id, worksheets_id)
254259
## Tests
255260
```
256261
test/test.py
257-
```
262+
```

microsoftgraph/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,11 @@ def drive_close_session(self, item_id, **kwargs):
483483
url = "https://graph.microsoft.com/beta/me/drive/items/{0}/workbook/closeSession".format(item_id)
484484
return self._post(url, **kwargs)
485485

486+
@token_required
487+
def drive_download_contents(self, item_id, params=None, **kwargs):
488+
url = "https://graph.microsoft.com/beta/me/drive/items/{0}/content".format(item_id)
489+
return self._get(url, params=params, **kwargs)
490+
486491
# Excel
487492
@token_required
488493
def excel_get_worksheets(self, item_id, params=None, **kwargs):
@@ -600,7 +605,7 @@ def _parse(self, response):
600605
if 'application/json' in response.headers['Content-Type']:
601606
r = response.json()
602607
else:
603-
r = response.text
608+
r = response.content
604609
if status_code in (200, 201, 202):
605610
return r
606611
elif status_code == 204:

0 commit comments

Comments
 (0)