-
-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR #240: bug fix to prevent File.from_url method from losing context
- Loading branch information
vvgrem@gmail.com
authored and
vvgrem@gmail.com
committed
Aug 4, 2020
1 parent
5525219
commit 5ae6400
Showing
9 changed files
with
32 additions
and
22 deletions.
There are no files selected for viewing
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,18 +1,17 @@ | ||
import os | ||
import tempfile | ||
|
||
from office365.runtime.auth.client_credential import ClientCredential | ||
from settings import settings | ||
|
||
from office365.runtime.auth.user_credential import UserCredential | ||
from office365.runtime.auth.client_credential import ClientCredential | ||
from office365.sharepoint.files.file import File | ||
|
||
abs_file_url = "{site_url}sites/team/Shared Documents/sample.docx".format(site_url=settings.get('url')) | ||
user_credentials = UserCredential(settings.get('user_credentials').get('username'), | ||
settings.get('user_credentials').get('password')) | ||
root_site_url = settings.get('url') | ||
client_credentials = ClientCredential(settings.get('client_credentials').get('client_id'), | ||
settings.get('client_credentials').get('client_secret')) | ||
|
||
file_name = os.path.basename(abs_file_url) | ||
abs_file_url = "{site_url}sites/team/Shared Documents/big_buck_bunny.mp4".format(site_url=root_site_url) | ||
with tempfile.TemporaryDirectory() as local_path: | ||
file_name = os.path.basename(abs_file_url) | ||
with open(os.path.join(local_path, file_name), 'wb') as local_file: | ||
file = File.from_url(abs_file_url).with_credentials(user_credentials).download(local_file).execute_query() | ||
file = File.from_url(abs_file_url).with_credentials(client_credentials).download(local_file).execute_query() | ||
print("'{0}' file has been downloaded into {1}".format(file.serverRelativeUrl, local_file.name)) |
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