You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I was using the library to download some files from sharepoint using file.read()
`
for _, row in tqdm.tqdm(df.iterrows()):
file_url = row['Relative URL']
local_path = os.path.join(local_folder, row['Relative URL'].lstrip('/'))
# Create the local directory if it doesn't exist
os.makedirs(os.path.dirname(local_path), exist_ok=True)
# Get the file from SharePoint
file = ctx.web.get_file_by_server_relative_path(str(file_url))
ctx.load(file)
ctx.execute_query()
# Save the file locally
with open(local_path, 'wb') as local_file:
file.read()
`
I had issues with files that had an appostrophe ex: < macdonald's.pdf > because the "'" is not encoded in the final url
Replacing file.read() by file.download(local_file).execute_query() It is working fine.
Is it expected behaviour ? is file.read() not supposed to handle the appostrophe also ?
Thank you for your answer !
The text was updated successfully, but these errors were encountered:
le-codeur-rapide
changed the title
Difference between file.read() and file.download(local_file).execute_query() in how url are encoded
Cannot download files with an apostrophe < ' > in path using file.read()
Aug 6, 2024
Hi I was using the library to download some files from sharepoint using file.read()
`
for _, row in tqdm.tqdm(df.iterrows()):
file_url = row['Relative URL']
local_path = os.path.join(local_folder, row['Relative URL'].lstrip('/'))
`
I had issues with files that had an appostrophe ex: < macdonald's.pdf > because the "'" is not encoded in the final url
Replacing file.read() by file.download(local_file).execute_query() It is working fine.
Is it expected behaviour ? is file.read() not supposed to handle the appostrophe also ?
Thank you for your answer !
The text was updated successfully, but these errors were encountered: