Skip to content

Commit

Permalink
#866 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed May 26, 2024
1 parent 6334eb3 commit bdaf895
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 3 additions & 1 deletion examples/onedrive/files/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
)

client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)
folder = client.users.get_by_principal_name(test_user_principal_name_alt).drive.root
user_drive = client.users.get_by_principal_name(test_user_principal_name_alt).drive
folder = user_drive.root

local_path = "../../data/Financial Sample.xlsx"
# local_path = "../../data/countries.json"
# file = folder.upload_file(local_path).execute_query()
with open(local_path, "rb") as f:
file = folder.upload_file(f).execute_query()
print("File {0} has been uploaded".format(file.web_url))
result = folder.children.get().execute_query()
2 changes: 1 addition & 1 deletion office365/onedrive/driveitems/driveItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ def subscriptions(self):
def set_property(self, name, value, persist_changes=True):
super(DriveItem, self).set_property(name, value, persist_changes)
if name == "parentReference":
self._resource_path.parent.patch(self.parent_reference.driveId)
pass
return self

def get_property(self, name, default_value=None):
Expand Down
9 changes: 3 additions & 6 deletions tests/onedrive/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ def test2_get_folder_permissions(self):

def test3_upload_file(self):
file_name = "SharePoint User Guide.docx"
path = "{0}/../data/{1}".format(os.path.dirname(__file__), file_name)
with open(path, "rb") as content_file:
file_content = content_file.read()
file_name = os.path.basename(path)
self.__class__.target_file = self.target_drive.root.upload(
file_name, file_content
file_path = "{0}/../data/{1}".format(os.path.dirname(__file__), file_name)
self.__class__.target_file = self.target_drive.root.upload_file(
file_path
).execute_query()
self.assertIsNotNone(self.target_file.web_url)

Expand Down

0 comments on commit bdaf895

Please sign in to comment.