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

How to upload a file in a subfolder of the Shared Documents folder? #91

Closed
mangano opened this issue Mar 20, 2019 · 4 comments
Closed

Comments

@mangano
Copy link

mangano commented Mar 20, 2019

Hello,
Great python client. I'm now using it regularly to load files from my linux box to a Sharepoint website.

I'm just unable to write into specific subfolders of the Shared Documents folder?

The example in file_operations.py seems to write only in the root folder:

In upload_file() there is:
file = upload_file_into_library(library, os.path.basename(path), file_content)

Note the 'basename' part

And then in upload_file_into_library we have:

target_file = target_library.root_folder.files.add(info)

Note the 'root_folder' part.

Any example on how to write into something like ShareDocuments/my_specific_folder ?

Thank you

@Bachatero
Copy link

Hi,
try this instead:

#target_file = targetLibrary.root_folder.files.add(info)
folder = ctx.web.get_folder_by_server_relative_url(app_settings['urlrel'])
target_file = folder.files.add(info)

where urlel is a path to your subfolder, e.g. '/sites/FRAReporting/Shared Documents/TEST'

Hope it helps.

m.

@Bachatero
Copy link

I mean,
app_settings = {
'urlrel': '/sites/FRAReporting/Shared Documents/TEST'
}

@mangano
Copy link
Author

mangano commented Mar 24, 2019

Fantastic. It worked!

Thank you,
Boris

@Kimjunkuk
Copy link
Contributor

Kimjunkuk commented Jun 24, 2022

Fantastic. It worked!

Thank you,!!!

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

No branches or pull requests

3 participants