-
-
Notifications
You must be signed in to change notification settings - Fork 370
Expand file tree
/
Copy pathupload.py
More file actions
15 lines (12 loc) · 552 Bytes
/
upload.py
File metadata and controls
15 lines (12 loc) · 552 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""
Demonstrates how to upload a small files (up to 4MB in size)
"""
from office365.sharepoint.client_context import ClientContext
from tests import test_team_site_url, test_user_credentials
ctx = ClientContext(test_team_site_url).with_credentials(test_user_credentials)
list_title = "Documents"
folder = ctx.web.lists.get_by_title(list_title).root_folder
path = "../../data/Financial Sample.xlsx"
with open(path, "rb") as f:
file = folder.files.upload(f).execute_query()
print("File has been uploaded into: {0}".format(file.serverRelativeUrl))