sy-ofb-python-sdk


Namesy-ofb-python-sdk JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryA Python interface for interacting with Microsoft's OneDrive.
upload_time2024-05-11 17:08:13
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License
keywords one drive microsoft sdk api cloud ofb onedrive for business
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OFB Python SDK

The `ofb-python-sdk` provides a Python interface for interacting with Microsoft's OneDrive. It simplifies the process of authenticating, uploading, downloading, and managing files on OneDrive through a simple and intuitive API. This SDK is particularly useful for developers who need to integrate OneDrive functionalities within their Python applications efficiently.

## Features

- Authentication with OAuth2
- Upload files to OneDrive (supports both small and large files)
- Download files from OneDrive
- Create and manage folders
- Delete files and folders
- Handle file conflicts with customizable behavior
- Rich progress bar integration for file uploads

## Installation

Install `ofb-python-sdk` using pip:

```bash
pip install sy-ofb-python-sdk
```

## Usage

To start using the SDK, you'll first need to import the `Client` class from the package.

```python
from ofb_python_sdk import Client
```

### Setup

Initialize the client with your application credentials:

```python
client = Client(
    client_id="your_client_id",
    client_secret="your_client_secret",
    refresh_token="your_refresh_token",
    redirect_uri="your_redirect_uri",
)
```

### Upload a File

```python
file_path = "/path/to/your/file"
file_data = open(file_path, "rb").read()
remote_path = "/path/to/onedrive/destination/file.txt"

try:
    response = client.upload_file(file_data, remote_path)
    print("Upload successful:", response.status_code)
except Exception as e:
    print("Upload failed:", e)
```

### Download a File

```python
remote_path = "/path/to/onedrive/file.txt"

try:
    file_data = client.download_file(remote_path)
    with open("downloaded_file.txt", "wb") as file:
        file.write(file_data)
    print("Download successful")
except Exception as e:
    print("Download failed:", e)
```

### Create a Folder

```python
folder_path = "/new/folder"

try:
    response = client.create_folder(folder_path)
    print("Folder creation successful:", response.status_code)
except Exception as e:
    print("Folder creation failed:", e)
```

### Delete a File

```python
remote_path = "/path/to/delete/file.txt"

try:
    response = client.delete_file(remote_path)
    print("Deletion successful:", response.status_code)
except Exception as e:
    print("Deletion failed:", e)
```

### Search a File

```python
keyword = "sometext"

try:
    result: list = client.search_files(keyword)
    print("Search successful:", result)
except Exception as e:
    print("Search failed:", e)
```

## Contributing

Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute to this project.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Support

If you need assistance or encounter any bugs, please open an issue on the project's [GitHub issues page](https://github.com/shing-yu/ofb-python-sdk/issues).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sy-ofb-python-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "one drive, microsoft, sdk, api, cloud, ofb, onedrive for business",
    "author": null,
    "author_email": "shingyu <xing_yv@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/cf/ed/c13d160acf622dc0e6f4ec00e03b627265a1b56b62fe379a2f52149e3b5a/sy_ofb_python_sdk-0.1.1.tar.gz",
    "platform": null,
    "description": "# OFB Python SDK\n\nThe `ofb-python-sdk` provides a Python interface for interacting with Microsoft's OneDrive. It simplifies the process of authenticating, uploading, downloading, and managing files on OneDrive through a simple and intuitive API. This SDK is particularly useful for developers who need to integrate OneDrive functionalities within their Python applications efficiently.\n\n## Features\n\n- Authentication with OAuth2\n- Upload files to OneDrive (supports both small and large files)\n- Download files from OneDrive\n- Create and manage folders\n- Delete files and folders\n- Handle file conflicts with customizable behavior\n- Rich progress bar integration for file uploads\n\n## Installation\n\nInstall `ofb-python-sdk` using pip:\n\n```bash\npip install sy-ofb-python-sdk\n```\n\n## Usage\n\nTo start using the SDK, you'll first need to import the `Client` class from the package.\n\n```python\nfrom ofb_python_sdk import Client\n```\n\n### Setup\n\nInitialize the client with your application credentials:\n\n```python\nclient = Client(\n    client_id=\"your_client_id\",\n    client_secret=\"your_client_secret\",\n    refresh_token=\"your_refresh_token\",\n    redirect_uri=\"your_redirect_uri\",\n)\n```\n\n### Upload a File\n\n```python\nfile_path = \"/path/to/your/file\"\nfile_data = open(file_path, \"rb\").read()\nremote_path = \"/path/to/onedrive/destination/file.txt\"\n\ntry:\n    response = client.upload_file(file_data, remote_path)\n    print(\"Upload successful:\", response.status_code)\nexcept Exception as e:\n    print(\"Upload failed:\", e)\n```\n\n### Download a File\n\n```python\nremote_path = \"/path/to/onedrive/file.txt\"\n\ntry:\n    file_data = client.download_file(remote_path)\n    with open(\"downloaded_file.txt\", \"wb\") as file:\n        file.write(file_data)\n    print(\"Download successful\")\nexcept Exception as e:\n    print(\"Download failed:\", e)\n```\n\n### Create a Folder\n\n```python\nfolder_path = \"/new/folder\"\n\ntry:\n    response = client.create_folder(folder_path)\n    print(\"Folder creation successful:\", response.status_code)\nexcept Exception as e:\n    print(\"Folder creation failed:\", e)\n```\n\n### Delete a File\n\n```python\nremote_path = \"/path/to/delete/file.txt\"\n\ntry:\n    response = client.delete_file(remote_path)\n    print(\"Deletion successful:\", response.status_code)\nexcept Exception as e:\n    print(\"Deletion failed:\", e)\n```\n\n### Search a File\n\n```python\nkeyword = \"sometext\"\n\ntry:\n    result: list = client.search_files(keyword)\n    print(\"Search successful:\", result)\nexcept Exception as e:\n    print(\"Search failed:\", e)\n```\n\n## Contributing\n\nContributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute to this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\nIf you need assistance or encounter any bugs, please open an issue on the project's [GitHub issues page](https://github.com/shing-yu/ofb-python-sdk/issues).\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A Python interface for interacting with Microsoft's OneDrive.",
    "version": "0.1.1",
    "project_urls": {
        "documentation": "https://github.com/shingyu/ofb-python-sdk",
        "homepage": "https://github.com/shingyu/ofb-python-sdk",
        "issues": "https://github.com/shingyu/ofb-python-sdk/issues",
        "repository": "https://github.com/shingyu/ofb-python-sdk"
    },
    "split_keywords": [
        "one drive",
        " microsoft",
        " sdk",
        " api",
        " cloud",
        " ofb",
        " onedrive for business"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2186f6b36bcf3d428c4cce9098d2c949776e1676b8853847ac011fddd77d32ca",
                "md5": "fbccabf09229e1e94767f797523dc906",
                "sha256": "0c2f23abf93135f025c3104ce2b04c45dc5eb285e4f48df7282c961bea681692"
            },
            "downloads": -1,
            "filename": "sy_ofb_python_sdk-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fbccabf09229e1e94767f797523dc906",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7130,
            "upload_time": "2024-05-11T17:08:11",
            "upload_time_iso_8601": "2024-05-11T17:08:11.954286Z",
            "url": "https://files.pythonhosted.org/packages/21/86/f6b36bcf3d428c4cce9098d2c949776e1676b8853847ac011fddd77d32ca/sy_ofb_python_sdk-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cfedc13d160acf622dc0e6f4ec00e03b627265a1b56b62fe379a2f52149e3b5a",
                "md5": "310288a4c93c111b91791d938d0d6362",
                "sha256": "fdb6909ec29f169f6093d40f3212fe8dfd3a69d8861f604caef63a925001fe54"
            },
            "downloads": -1,
            "filename": "sy_ofb_python_sdk-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "310288a4c93c111b91791d938d0d6362",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9592,
            "upload_time": "2024-05-11T17:08:13",
            "upload_time_iso_8601": "2024-05-11T17:08:13.082864Z",
            "url": "https://files.pythonhosted.org/packages/cf/ed/c13d160acf622dc0e6f4ec00e03b627265a1b56b62fe379a2f52149e3b5a/sy_ofb_python_sdk-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-11 17:08:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "shingyu",
    "github_project": "ofb-python-sdk",
    "github_not_found": true,
    "lcname": "sy-ofb-python-sdk"
}
        
Elapsed time: 0.30274s