Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

get_file_by_server_relative_url length attribute is -1 even when subsequent download_session returns many bytes

Open nmz787-intel opened this issue 1 year ago • 0 comments

file_metadata = source_file.expand(["versions", "listItemAllFields", "Author"]).get().execute_query()
expected_data_length = source_file.length
local_file = io.BytesIO()
def print_download_progress(offset):
    print("Downloaded '{}' bytes... of: {}".format(offset, filepath))
source_file.download_session(local_file, print_download_progress).execute_query_retry(max_retry=100)
downloaded_length = local_file.getbuffer().nbytes

problem is that expected_data_length often comes back as -1... even when the subsequent downloaded_length returns thousands of bytes. If I keep re-trying this code in a loop... since there is a mismatch, eventually (sometimes after 100s of attempts) they will match.

Using latest version (2.5.6).

nmz787-intel avatar Mar 01 '24 18:03 nmz787-intel