Open odairvaz opened 4 years ago
I could make a Folder.put_file method that would be a wrapper for:
with open(financial_sample, mode='rb') as file:
fileContent = file.read()
folder.upload_file(fileContent, financial_sample)
@jasonrollins can you give me an example please.
Sure:
`from shareplum import Site from shareplum import Office365 from shareplum.site import Version
url = "https://jrollins.sharepoint.com/sites/TestSite"
authcookie = Office365('https://jrollins.sharepoint.com', username='jrollins@blahblahblah.com', password='hunter2').GetCookies() site = Site(url, version=Version.v2013, authcookie=authcookie)
folder = site.Folder('Shared Documents/This Folder')
with open("cn0510.pdf", mode='rb') as file: # b is important -> binary fileContent = file.read()
folder.upload_file(fileContent, "my.pdf")`
After reading the documentation and doing some research I can’t find anyway to upload files to SharePoint without iterating through the file. I must upload multiple csv files and those files contain a lot of data, is there anyway to upload those files without having to iterate through them?
Here’s my script: `from shareplum import Site from shareplum import Office365 from shareplum.site import Version
files to upload to sharepoint
users = "./users.csv" company = "./company.csv" finance = "./fianace.csv" mapdata = "./mapdata.csv" financial_sample = "./Financial Sample.xlsx"
Office 365 Authentication
authcookie = Office365('https://tenant.sharepoint.com', username='username@tenant.com', password='password').GetCookies() site = Site('https://tenant.sharepoint.com/sites/folder_name', version=Version.v365, authcookie=authcookie)
folder = site.Folder('Documents partages/data')
with open(financial_sample, mode='rb') as file: fileContent = file.read() folder.upload_file(fileContent, financial_sample)`
Thanks in advance