Skip to content

How to return the URL of an uploaded document #2

@rickmedlin

Description

@rickmedlin

With office365.runtime, I did it as shown below. How would you suggest doing it with SharePlum?

# Get authorization from the site url.
ctx = ClientContext(siteurl, ctx_auth)

with open(localpath, 'rb') as content_file:
    file_content = content_file.read()
    
dir, name = os.path.split(remotepath)
file = ctx.web.get_folder_by_server_relative_url(dir).upload_file(name, file_content).execute_query()
sourcedoc = '{' + file.properties['UniqueId'] + '}'

fullurl = siteurl + '_layouts/15/Doc.aspx?sourcedoc=' + urllib.parse.quote(sourcedoc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions