Python SharePoint API for folder or file operations (download, upload, delete)
Project description
Sharepoint API
Install
pip install sharepoint-api
Setup Config
Create config.yaml
TENANT_NAME: ""
SITE_NAME: ""
CLIENT_ID: "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx"
CLIENT_SECRET: ""
LIBRARY_NAME: "Shared Documents"
Currently I am using Sharepoint "Shared Documents" area
If you needs to change -> Change in YAML file
LIBRARY_NAME: ""
Examples:
from sharepoint_api import SharePoint
sharepoint = SharePoint(config_path='config.yaml')
sp_path = "Myfiles/temp"
folder = sharepoint.get_folder(sp_path)
print(f"Folder: {folder}")
files, subfolders = sharepoint.list_folder_items()
print(files, subfolders)
# Download file
sharepoint.download_file(sp_path="Myfiles/temp/exam_result_v1.csv", local_file_path="/home/user/myfiles")
# Delete File
sharepoint.delete_file("MyFiles/models/yolo11n-obb.pt")
# Get file metadata
file_metadata = sharepoint.get_file_metadata("MyFiles/videos/sample_video.mp4")
print(f"File Metadata: {file_metadata.properties}")
# Upload File
sharepoint.upload_file("sample/exam_result_v1.csv", "Myfiles/temp/upload_test")
# Download Folder
sharepoint.download_folder(sp_path="Myfiles/temp/test1", local_file_path="/home/user/myfiles/sample")
# Create Folder
sharepoint.create_folder("Myfiles/temp/test2")
# Delete Folder
sharepoint.delete_folder("Myfiles/temp/test2")
# Upload Folder
sharepoint.upload_folder("sample/test", "Myfiles/gallery")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sharepoint_api-1.4.1.tar.gz
(5.0 kB
view details)