Skip to content

Commit e819327

Browse files
committed
fix: clean up upload_download.py path, remove os import, use Path
1 parent eca0f55 commit e819327

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

examples/onedrive/files/upload_download.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@
44
Requires delegated permission Files.ReadWrite.
55
"""
66

7-
import os
87
from pathlib import Path
98

109
from office365.graph_client import GraphClient
1110
from tests import test_client_id, test_password, test_tenant, test_username
1211

1312
FILE_NAME = "Financial Sample.xlsx"
14-
LOCAL_PATH = Path(__file__).parent.parent.parent.parent / "tests" / "data" / FILE_NAME
13+
LOCAL_PATH = Path("../../data") / FILE_NAME
1514

1615
client = GraphClient(tenant=test_tenant).with_username_and_password(test_client_id, test_username, test_password)
1716

1817
with open(LOCAL_PATH, "rb") as f:
1918
uploaded = client.me.drive.root.upload_file(f).execute_query()
2019

21-
download_path = os.path.join(os.path.dirname(__file__), FILE_NAME)
20+
download_path = Path(__file__).parent / FILE_NAME
2221
with open(download_path, "wb") as f:
2322
uploaded.download(f).execute_query()
2423

25-
print(f"Uploaded and downloaded: {FILE_NAME} ({os.path.getsize(download_path):,} bytes)")
24+
print(f"Uploaded and downloaded: {FILE_NAME} ({download_path.stat().st_size:,} bytes)")

0 commit comments

Comments
 (0)