How to use the onedrivesdk.ItemRequestBuilder function in onedrivesdk

To help you get started, we’ve selected a few onedrivesdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github epam / OneDrive-L / onedrive_service / src / onedrive_service / util.py View on Github external
def cancel_upload_session(self, upload_url):
        """
        Cancel an upload session
        :param upload_url: str
        :return:
        """
        req = onedrivesdk.ItemRequestBuilder(upload_url, self.client)
        return req.delete()
github epam / OneDrive-L / onedrive_service / src / onedrive_service / util.py View on Github external
def upload_session_status(self, upload_url):
        """
        Check the upload session status

        You can request the status of the file at any time,
        not just when the upload has failed.
        The server will respond with a list of missing
        byte ranges that need to be uploaded.
        :param upload_url:
        :return: onedrivesdk.UploadSession
        """
        builder = onedrivesdk.ItemRequestBuilder(upload_url, self.client)

        req = builder.request()
        req.method = 'GET'
        raw_response = json.loads(req.send().content)
        entity = onedrivesdk.UploadSession(raw_response)

        return entity
github epam / OneDrive-L / onedrive_service / src / onedrive_service / util.py View on Github external
def upload_session(self, upload_url, data, total, next_range=0):
        """
        Upload the file, or a portion of the file
        It is possible to upload the entire file in one fragment up to 60 MiB

        The recommended fragment size is between 5-10 MiB.
        :param upload_url: str, url to upload
        :param data: data to include in the body of the request
        :param total: integer, all fragments size in bytes
        :param next_range: integer,  next expected ranges value to determine
        where to start the next fragment
        :return: onedrivesdk.UploadSession
        """
        data_length = len(data)
        builder = onedrivesdk.ItemRequestBuilder(upload_url, self.client)

        req = builder.request()
        req.method = 'PUT'

        # init header options
        header_options = self._init_upload_session_header(next_range,
                                                          data_length, total)
        for option in header_options:
            req.append_option(option)

        # send chunk of data
        raw_response = req.send(data=data)
        entity = onedrivesdk.UploadSession(json.loads(raw_response.content))

        return entity