Skip to content

Commit b17f09a

Browse files
authored
Merge pull request #17 from richardARPANET/master
Adds drive_download_shared_contents method
2 parents 19c3f0b + bd650d9 commit b17f09a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

microsoftgraph/client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,19 @@ def drive_download_contents(self, item_id, params=None, **kwargs):
488488
url = "https://graph.microsoft.com/beta/me/drive/items/{0}/content".format(item_id)
489489
return self._get(url, params=params, **kwargs)
490490

491+
def drive_download_shared_contents(self, share_id, params=None, **kwargs):
492+
base64_value = base64.b64encode(share_id.encode()).decode()
493+
encoded_share_url = (
494+
'u!' +
495+
base64_value.rstrip('=').replace('/', '_').replace('+', '-')
496+
)
497+
url = "https://graph.microsoft.com/beta/shares/{0}/driveItem".format(
498+
encoded_share_url
499+
)
500+
drive_item = self._get(url)
501+
file_download_url = drive_item['@microsoft.graph.downloadUrl']
502+
return drive_item['name'], requests.get(file_download_url).content
503+
491504
@token_required
492505
def drive_download_large_contents(self, downloadUrl, offset, size):
493506
headers = {"Range": f'bytes={offset}-{size + offset - 1}'}

0 commit comments

Comments
 (0)