Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GeorgeDoughty opened this issue Aug 16, 2024 · 1 comment
Open
Labels

Comments

@GeorgeDoughty
Copy link

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
@vgrem vgrem added the question label Sep 5, 2024
@F-Joubert
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants