Storage provider for sharepoint service
Project description
Installation
Use pip:
pip install sp_storage
or
pip install git+https://github.com/shineum/sp_storage.git
Getting Started
Set the following in your settings.py:
SHAREPOINT_TENANT = '<tenant name>'
SHAREPOINT_TENANT_ID = '<tenant id - uuid format>'
SHAREPOINT_CLIENT_ID = '<client id - uuid format>'
SHAREPOINT_CLIENT_SECRET = '<client secret>'
SHAREPOINT_USERNAME = '<username>'
SHAREPOINT_PASSWORD = '<password>'
SHAREPOINT_SITE_NAME = '<site name>'
SHAREPOINT_ROOT_DIR = '<root dir>'
SHAREPOINT_BLOB_MAX_MEMORY_SIZE = '<blob file size - defulat 16M>'
note: If 'SHAREPOINT_CLIENT_ID' and 'SHAREPOINT_CLIENT_SECRET' are provided 'SHAREPOINT_USERNAME' and 'SHAREPOINT_PASSWORD' will be ignored.
Usage
Fields
Set the default storage as 'sp_storage.sharepoint.SharepointStorage' or import SharepointStorage and set storage for each models.
DEFAULT_FILE_STORAGE = 'sp_storage.sharepoint.SharepointStorage'
# model
from django.db import models
class Sample(models.Model):
pdf = models.FileField(upload_to='pdfs')
or
# model
from sp_storage.sharepoint import SharepointStorage
from django.db import models
class Sample(models.Model):
pdf = models.FileField(upload_to='pdfs', storage=SharepointStorage)
Storage
>>> from sp_storage.sharepoint import SharepointStorage
>>> storage = SharepointStorage()
>>> storage.exists('storage_test')
False
>>> file = storage.open('storage_test', 'w')
>>> file.write('storage test')
>>> file.close()
>>> storage.exists('storage_test')
True
>>> file = storage.open('storage_test', 'r')
>>> file.read()
b'storage test'
>>> file.close()
>>> storage.delete('storage_test')
>>> storage.exists('storage_test')
False
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sp_storage-0.0.1.tar.gz.
File metadata
- Download URL: sp_storage-0.0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f822cde7e3371cc182d39f627c2085092cc819f7d855aa8e7bae69b507685772
|
|
| MD5 |
3d4fab21315df8bd7e16f2237ef45456
|
|
| BLAKE2b-256 |
a446ea965a99fe63f773c52c510f6d2ff4d20d50a7fbf4d05a7223afbc50b18a
|
File details
Details for the file sp_storage-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sp_storage-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11061f192102c146fcd3b25e062674c26e82cadae1ec7e47b7ec0a5422148ea5
|
|
| MD5 |
872740959774408b434dbd5dec090089
|
|
| BLAKE2b-256 |
fe2a6e678c552ed3dc661d9d699b0ce735d404129b1f23462566bc35e59051f9
|