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

Upload new data to a sharepoint file and increment the version.

Open GeorgeDoughty opened this issue 1 year ago • 1 comments

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_file via sp.Folder
  • save_binary_stream on sp.File

GeorgeDoughty avatar Aug 16 '24 08:08 GeorgeDoughty

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()

image

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.

F-Joubert avatar Sep 30 '24 23:09 F-Joubert