How to use the azure-storage-file.azure.storage.file._serialization._validate_and_format_range_headers function in azure-storage-file

To help you get started, we’ve selected a few azure-storage-file 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 Azure / azure-storage-python / azure-storage-file / azure / storage / file / fileservice.py View on Github external
:returns: a list of valid ranges
        :rtype: a list of :class:`~azure.storage.file.models.FileRange`
        '''
        _validate_not_none('share_name', share_name)
        _validate_not_none('file_name', file_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host_locations = self._get_host_locations()
        request.path = _get_path(share_name, directory_name, file_name)
        request.query = {
            'comp': 'rangelist',
            'timeout': _int_to_str(timeout),
            'sharesnapshot': _to_str(snapshot),
        }
        if start_range is not None:
            _validate_and_format_range_headers(
                request,
                start_range,
                end_range,
                start_range_required=False,
                end_range_required=False)

        return self._perform_request(request, _convert_xml_to_ranges)
github Azure / azure-storage-python / azure-storage-file / azure / storage / file / fileservice.py View on Github external
'''
        _validate_not_none('share_name', share_name)
        _validate_not_none('file_name', file_name)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host_locations = self._get_host_locations()
        request.path = _get_path(share_name, directory_name, file_name)
        request.query = {
            'comp': 'range',
            'timeout': _int_to_str(timeout),
        }
        request.headers = {
            'Content-Length': '0',
            'x-ms-write': 'clear',
        }
        _validate_and_format_range_headers(
            request, start_range, end_range)

        self._perform_request(request)
github Azure / azure-storage-python / azure-storage-file / azure / storage / file / fileservice.py View on Github external
The start_range and end_range params are inclusive.
            Ex: start_range=0, end_range=511 will download first 512 bytes of file.
        :param bool validate_content:
            If true, calculates an MD5 hash of the page content. The storage 
            service checks the hash of the content that has arrived
            with the hash that was sent. This is primarily valuable for detecting 
            bitflips on the wire if using http instead of https as https (the default) 
            will already validate. Note that this MD5 hash is not stored with the 
            file.
        :param int timeout:
            The timeout parameter is expressed in seconds.
        '''
        request = self._get_basic_update_file_http_request(share_name, directory_name, file_name, timeout=timeout)

        _validate_not_none('data', data)
        _validate_and_format_range_headers(request, start_range, end_range)
        request.body = _get_data_bytes_only('data', data)

        if validate_content:
            computed_md5 = _get_content_md5(request.body)
            request.headers['Content-MD5'] = _to_str(computed_md5)

        self._perform_request(request)
github Azure / azure-storage-python / azure-storage-file / azure / storage / file / fileservice.py View on Github external
is less than or equal to 4 MB in size.
        :param int timeout:
            The timeout parameter is expressed in seconds.
        :param str snapshot:
            A string that represents the snapshot version, if applicable.
        :return: A File with content, properties, and metadata.
        :rtype: :class:`~azure.storage.file.models.File`
        '''
        _validate_not_none('share_name', share_name)
        _validate_not_none('file_name', file_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host_locations = self._get_host_locations()
        request.path = _get_path(share_name, directory_name, file_name)
        request.query = {'timeout': _int_to_str(timeout), 'sharesnapshot': _to_str(snapshot)}
        _validate_and_format_range_headers(
            request,
            start_range,
            end_range,
            start_range_required=False,
            end_range_required=False,
            check_content_md5=validate_content)

        return self._perform_request(request, _parse_file,
                                     [file_name, validate_content],
                                     operation_context=_context)
github Azure / azure-storage-python / azure-storage-file / azure / storage / file / fileservice.py View on Github external
https://myaccount.file.core.windows.net/myshare/mydir/myfile
            https://otheraccount.file.core.windows.net/myshare/mydir/myfile?sastoken
        :param int source_start_range:
            Start of byte range to use for updating a section of the file.
            The range can be up to 4 MB in size.
            The start_range and end_range params are inclusive.
            Ex: start_range=0, end_range=511 will download first 512 bytes of file.
        :param int timeout:
            The timeout parameter is expressed in seconds.
        '''

        request = self._get_basic_update_file_http_request(share_name, directory_name, file_name, timeout=timeout)

        _validate_not_none('source', source)
        _validate_and_format_range_headers(request, start_range, end_range)
        _validate_and_format_range_headers(request,
                                           source_start_range,
                                           source_start_range+(end_range-start_range),
                                           is_source=True)

        request.headers.update({
            'x-ms-copy-source': _to_str(source),
            'Content-Length': _int_to_str(0)
        })

        self._perform_request(request)
github Azure / azure-storage-python / azure-storage-file / azure / storage / file / fileservice.py View on Github external
Examples:
            https://myaccount.file.core.windows.net/myshare/mydir/myfile
            https://otheraccount.file.core.windows.net/myshare/mydir/myfile?sastoken
        :param int source_start_range:
            Start of byte range to use for updating a section of the file.
            The range can be up to 4 MB in size.
            The start_range and end_range params are inclusive.
            Ex: start_range=0, end_range=511 will download first 512 bytes of file.
        :param int timeout:
            The timeout parameter is expressed in seconds.
        '''

        request = self._get_basic_update_file_http_request(share_name, directory_name, file_name, timeout=timeout)

        _validate_not_none('source', source)
        _validate_and_format_range_headers(request, start_range, end_range)
        _validate_and_format_range_headers(request,
                                           source_start_range,
                                           source_start_range+(end_range-start_range),
                                           is_source=True)

        request.headers.update({
            'x-ms-copy-source': _to_str(source),
            'Content-Length': _int_to_str(0)
        })

        self._perform_request(request)

azure-storage-file

Microsoft Azure Storage File Client Library for Python

MIT
Latest version published 5 years ago

Package Health Score

75 / 100
Full package analysis