Office365-REST-Python-Client
Office365-REST-Python-Client copied to clipboard
Upload new data to a sharepoint file and increment the version.
I am trying to upload a file to SharePoint and increment the version, but every time I upload a file it keeps the version at 1.0. Is this possible?
I have tried the following methods:
upload_filevia sp.Foldersave_binary_streamon sp.File
This is just a temporary solution, but you can increment the version by updating the title or any other list item property of the file after you upload it.
with open(local_path, "rb") as f:
file = folder.files.upload(f).execute_query()
file_list_item = ctx.web.get_list_item(
file.serverRelativeUrl.replace("#", "%23")
)
file_list_item.set_property("Title", title).update().execute_query()
Now having said that, does anyone know how to update a list item's title WITHOUT incrementing the version? That doubled storage space to make an item easier to search is pretty painful. And our folder / file names can't be changed as they're used by an external system.