-
-
Save KyMidd/2369b685b5ef52f2d7a7ec96f2051983 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def download_file_for_user(file_name, file_url, headers): | |
| try: | |
| if ".sharepoint.com/sites/" in file_url: | |
| # ... | |
| # Try to access the file after normalizing the path | |
| normalized_path = unicodedata.normalize("NFKC", file_relative_path_raw).replace('\u202f', ' ') | |
| if normalized_path != file_relative_path_raw: | |
| normalized_encoded = urllib.parse.quote(normalized_path, safe="/") | |
| graph_url = f"https://graph.microsoft.com/v1.0/sites/{site_id}/drives/{drive_id}/root:/{normalized_encoded}:/content" | |
| print(f"🟢 Attempting normalized path download URL: {graph_url}") | |
| resp = requests.get(graph_url, headers=headers) | |
| if resp.status_code == 200: | |
| print(f"🟢 Download succeeded from SharePoint site using normalized path: {graph_url}") | |
| return resp.content | |
| else: | |
| print(f"🚫 Normalized path download failed: {resp.status_code} - {resp.text}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment