-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[UpdatePage]add upload_pages_from_url sync and async #6960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1492,6 +1492,121 @@ async def upload_page( # type: ignore | |
| except StorageErrorException as error: | ||
| process_storage_error(error) | ||
|
|
||
| @distributed_trace_async | ||
| async def upload_pages_from_url(self, source_url, # type: str | ||
| range_start, | ||
| range_end, | ||
| source_range_start, | ||
| source_content_md5=None, | ||
| source_if_modified_since=None, | ||
| source_if_unmodified_since=None, source_if_match=None, source_if_none_match=None, | ||
| lease=None, if_sequence_number_lte=None, if_sequence_number_lt=None, | ||
| if_sequence_number_eq=None, if_modified_since=None, if_unmodified_since=None, | ||
| if_match=None, if_none_match=None, timeout=None | ||
| ): | ||
|
||
| """ | ||
| Updates a range of pages to a page blob where the contents are read from a URL. | ||
|
|
||
| :param str source_url: | ||
| The URL of the source data. It can point to any Azure Blob or File, that is either public or has a | ||
| shared access signature attached. | ||
| :param int range_start: | ||
| Start of byte range to use for writing to a section of the blob. | ||
| Pages must be aligned with 512-byte boundaries, the start offset | ||
| must be a modulus of 512 and the end offset must be a modulus of | ||
| 512-1. Examples of valid byte ranges are 0-511, 512-1023, etc. | ||
| :param int range_end: | ||
| End of byte range to use for writing to a section of the blob. | ||
| Pages must be aligned with 512-byte boundaries, the start offset | ||
| must be a modulus of 512 and the end offset must be a modulus of | ||
| 512-1. Examples of valid byte ranges are 0-511, 512-1023, etc. | ||
| :param int source_range_start: | ||
| This indicates the start of the range of bytes(inclusive) that has to be taken from the copy source. | ||
| The service will read the same number of bytes as the destination range (end_range-start_range). | ||
| :param str source_content_md5: | ||
| If given, the service will calculate the MD5 hash of the block content and compare against this value. | ||
| :param datetime source_if_modified_since: | ||
| A DateTime value. Azure expects the date value passed in to be UTC. | ||
| If timezone is included, any non-UTC datetimes will be converted to UTC. | ||
| If a date is passed in without timezone info, it is assumed to be UTC. | ||
| Specify this header to perform the operation only | ||
| if the source resource has been modified since the specified time. | ||
| :param datetime source_if_unmodified_since: | ||
| A DateTime value. Azure expects the date value passed in to be UTC. | ||
| If timezone is included, any non-UTC datetimes will be converted to UTC. | ||
| If a date is passed in without timezone info, it is assumed to be UTC. | ||
| Specify this header to perform the operation only if | ||
| the source resource has not been modified since the specified date/time. | ||
| :param str source_if_match: | ||
| An ETag value, or the wildcard character (*). Specify this header to perform | ||
| the operation only if the source resource's ETag matches the value specified. | ||
| :param str source_if_none_match: | ||
| An ETag value, or the wildcard character (*). Specify this header | ||
| to perform the operation only if the source resource's ETag does not match | ||
| the value specified. Specify the wildcard character (*) to perform | ||
| the operation only if the source resource does not exist, and fail the | ||
| operation if it does exist. | ||
| :param str lease: | ||
| Required if the blob has an active lease. | ||
| :param int if_sequence_number_lte: | ||
| If the blob's sequence number is less than or equal to | ||
| the specified value, the request proceeds; otherwise it fails. | ||
| :param int if_sequence_number_lt: | ||
| If the blob's sequence number is less than the specified | ||
| value, the request proceeds; otherwise it fails. | ||
| :param int if_sequence_number_eq: | ||
| If the blob's sequence number is equal to the specified | ||
| value, the request proceeds; otherwise it fails. | ||
| :param datetime if_modified_since: | ||
| A DateTime value. Azure expects the date value passed in to be UTC. | ||
| If timezone is included, any non-UTC datetimes will be converted to UTC. | ||
| If a date is passed in without timezone info, it is assumed to be UTC. | ||
| Specify this header to perform the operation only | ||
| if the resource has been modified since the specified time. | ||
| :param datetime if_unmodified_since: | ||
| A DateTime value. Azure expects the date value passed in to be UTC. | ||
| If timezone is included, any non-UTC datetimes will be converted to UTC. | ||
| If a date is passed in without timezone info, it is assumed to be UTC. | ||
| Specify this header to perform the operation only if | ||
| the resource has not been modified since the specified date/time. | ||
| :param str if_match: | ||
| An ETag value, or the wildcard character (*). Specify this header to perform | ||
| the operation only if the resource's ETag matches the value specified. | ||
| :param str if_none_match: | ||
| An ETag value, or the wildcard character (*). Specify this header | ||
| to perform the operation only if the resource's ETag does not match | ||
| the value specified. Specify the wildcard character (*) to perform | ||
| the operation only if the resource does not exist, and fail the | ||
| operation if it does exist. | ||
| :param ~azure.storage.blob.models.CustomerProvidedEncryptionKey cpk: | ||
| Encrypts the data on the service-side with the given key. | ||
| Use of customer-provided keys must be done over HTTPS. | ||
| As the encryption key itself is provided in the request, | ||
| a secure connection must be established to transfer the key. | ||
| :param int timeout: | ||
| The timeout parameter is expressed in seconds. | ||
| """ | ||
|
|
||
| options = self._upload_pages_from_url_options( | ||
| source_url, | ||
| range_start, | ||
| range_end, | ||
| source_range_start, | ||
| source_content_md5=source_content_md5, | ||
| lease=lease, | ||
| if_sequence_number_lte=if_sequence_number_lte, if_sequence_number_lt=if_sequence_number_lt, | ||
| if_sequence_number_eq=if_sequence_number_eq, | ||
| if_modified_since=if_modified_since, | ||
| if_unmodified_since=if_unmodified_since, if_match=if_match, | ||
| if_none_match=if_none_match, source_if_modified_since=source_if_modified_since, | ||
| source_if_unmodified_since=source_if_unmodified_since, source_if_match=source_if_match, | ||
| source_if_none_match=source_if_none_match, timeout=timeout | ||
| ) | ||
| try: | ||
| return await self._client.page_blob.upload_pages_from_url(**options) # type: ignore | ||
| except StorageErrorException as error: | ||
| process_storage_error(error) | ||
|
|
||
| @distributed_trace_async | ||
| async def clear_page(self, start_range, end_range, **kwargs): | ||
| # type: (int, int) -> Dict[str, Union[str, datetime]] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.