Skip to content

Uploadtosharepoint

flowtask.components.UploadToSharepoint

UploadToSharepoint

UploadToSharepoint(loop=None, job=None, stat=None, **kwargs)

Bases: SharepointClient, UploadToBase

UploadToSharepoint

Overview

    The UploadToSharepoint class is a component for uploading files or entire directories to a SharePoint site.
    It supports various configuration options for selecting files by name, extension, or pattern, and includes
    functionality for recursive directory searches.

.. table:: Properties
:widths: auto

    +----------------+----------+-----------+---------------------------------------------------------------+
    | Name           | Required | Summary                                                                   |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | credentials    |   Yes    | A dictionary with SharePoint credentials: `username`, `password`,         |
    |                |          | `tenant`, and `site`.                                                     |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | source         |   Yes    | A dictionary specifying the source directory, filename, and/or file       |
    |                |          | extension for selecting files to upload.                                  |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | destination    |   Yes    | A dictionary defining the SharePoint destination directory.               |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | whole_dir      |   No     | Boolean indicating if the entire source directory should be uploaded.     |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | recursive      |   No     | Boolean specifying whether to search recursively within directories.      |
    +----------------+----------+-----------+---------------------------------------------------------------+

Returns

    This component uploads files to a specified SharePoint directory and returns the upload result status.
    It logs the upload activity and records metrics for the number of files uploaded. If no files are found
    or the configuration is incomplete, it raises an error. The upload can handle both individual files and
    entire folders, depending on configuration.


Example:

```yaml
UploadToSharepoint:
  credentials:
    username: sharepoint_username
    password: sharepoint_password
    tenant: symbits
    site: trocstorage
  destination:
    directory: Shared Documents/Optimum Sales Files
  masks:
    '{today}':
    - today
    - mask: '%Y%m%d%H%M%S'
```

run async

run()

Upload a File to Sharepoint

start async

start(**kwargs)

start Method.