Hi @Raj Pandit
Thanks for your time in advance ,if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.
By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others." and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:
How to upload CSV file of size more than 250MB to SharePoint in Office 365 Using Python
Issue Symptom:
Failed to upload large files more than 250MB to SharePoint by Office365-REST-Python-Client
Solution
Upload large file by following code
import os
from office365.sharepoint.client_context import ClientContext
from tests import test_user_credentials, test_team_site_url
ctx = ClientContext(test_team_site_url).with_credentials(test_user_credentials)
target_url = "/sites/team/Shared Documents"
target_folder = ctx.web.get_folder_by_server_relative_url(target_url)
size_chunk = 1000000
# local_path = "../../../tests/data/big_buck_bunny.mp4"
local_path = "../../../tests/data/SharePoint User Guide.docx"
def print_upload_progress(offset):
file_size = os.path.getsize(local_path)
print("Uploaded '{0}' bytes from '{1}'...[{2}%]".format(offset, file_size, round(offset / file_size * 100, 2)))
with open(local_path, 'rb') as f:
uploaded_file = target_folder.files.create_upload_session(f, size_chunk,
print_upload_progress).execute_query()
#uploaded_file = target_folder.files.create_upload_session(local_path, size_chunk, print_upload_progress).execute_query()
print('File {0} has been uploaded successfully'.format(uploaded_file.serverRelativeUrl))
More sample for reference
https://github.com/vgrem/Office365-REST-Python-Client/tree/master/examples/sharepoint/files
You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!
Hello RaytheonXie,
Appreciate that you reached out to me and it is only in the right spirit for me to share the solution for the benefit of the larger community.
Hope you are doing well.
I found the solution here - the author of this Python library gave an example of how to upload if the file is big enough - it uses the concept of uploading in chunks-
https://github.com/vgrem/Office365-REST-Python-Client/tree/master/examples/sharepoint/files
This rightly helped me to find a solution to my requirement.