-
-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for sitepages namespace in OneDrive, upload_folder me…
…thod
- Loading branch information
Showing
32 changed files
with
435 additions
and
109 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,20 @@ | ||
""" | ||
Demonstrates how to upload files from a local folder into OneDrive drive | ||
""" | ||
|
||
import os | ||
from os.path import isfile, join | ||
|
||
from office365.graph_client import GraphClient | ||
from office365.runtime.client_request_exception import ClientRequestException | ||
from tests.graph_case import acquire_token_by_username_password | ||
from office365.onedrive.driveitems.driveItem import DriveItem | ||
from tests import test_client_id, test_password, test_tenant, test_username | ||
|
||
client = GraphClient(acquire_token_by_username_password) | ||
remote_drive = client.me.drive | ||
local_path = "../../data" | ||
|
||
for name in os.listdir(local_path): | ||
path = join(local_path, name) | ||
if isfile(path): | ||
try: | ||
with open(path, "rb") as local_file: | ||
uploaded_file = remote_drive.root.upload_file( | ||
local_file | ||
).execute_query() | ||
print("File '{0}' uploaded into '{1}'".format(path, uploaded_file.web_url)) | ||
except ClientRequestException as e: | ||
print( | ||
"An error occured while uploading a file {0}: {1}".format( | ||
path, e.message | ||
) | ||
) | ||
def print_progress(uploaded_file): | ||
# type: (DriveItem)-> None | ||
print("File has been uploaded into '{0}'".format(uploaded_file.web_url)) | ||
|
||
|
||
client = GraphClient.with_username_and_password( | ||
test_tenant, test_client_id, test_username, test_password | ||
) | ||
local_path = "../../data" | ||
target_folder = client.me.drive.root.get_by_path("Import") | ||
target_folder.upload_folder(local_path, print_progress).execute_query() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Demonstrates how to upload files from a local folder into OneDrive drive | ||
""" | ||
|
||
import os | ||
from os.path import isfile, join | ||
|
||
from office365.graph_client import GraphClient | ||
from office365.runtime.client_request_exception import ClientRequestException | ||
from tests import test_client_id, test_password, test_tenant, test_username | ||
|
||
client = GraphClient.with_username_and_password( | ||
test_tenant, test_client_id, test_username, test_password | ||
) | ||
remote_drive = client.me.drive | ||
local_path = "../../data" | ||
|
||
for name in os.listdir(local_path): | ||
path = join(local_path, name) | ||
if isfile(path): | ||
try: | ||
with open(path, "rb") as local_file: | ||
uploaded_file = remote_drive.root.upload_file( | ||
local_file | ||
).execute_query() | ||
print("File '{0}' uploaded into '{1}'".format(path, uploaded_file.web_url)) | ||
except ClientRequestException as e: | ||
print( | ||
"An error occured while uploading a file {0}: {1}".format( | ||
path, e.message | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.