How to use check_content_md5 method in localstack

Best Python code snippet using localstack_python

_serialization.py

Source:_serialization.py Github

copy

Full Screen

1# -------------------------------------------------------------------------2# Copyright (c) Microsoft Corporation. All rights reserved.3# Licensed under the MIT License. See License.txt in the project root for4# license information.5# --------------------------------------------------------------------------6from azure.storage.common._common_conversion import _str7from azure.storage.common._error import (8 _validate_not_none,9 _ERROR_START_END_NEEDED_FOR_MD5,10 _ERROR_RANGE_TOO_LARGE_FOR_MD5,11)12def _get_path(share_name=None, directory_name=None, file_name=None):13 '''14 Creates the path to access a file resource.15 share_name:16 Name of share.17 directory_name:18 The path to the directory.19 file_name:20 Name of file.21 '''22 if share_name and directory_name and file_name:23 return '/{0}/{1}/{2}'.format(24 _str(share_name),25 _str(directory_name),26 _str(file_name))27 elif share_name and directory_name:28 return '/{0}/{1}'.format(29 _str(share_name),30 _str(directory_name))31 elif share_name and file_name:32 return '/{0}/{1}'.format(33 _str(share_name),34 _str(file_name))35 elif share_name:36 return '/{0}'.format(_str(share_name))37 else:38 return '/'39def _validate_and_format_range_headers(request, start_range, end_range, start_range_required=True,40 end_range_required=True, check_content_md5=False):41 # If end range is provided, start range must be provided42 if start_range_required or end_range is not None:43 _validate_not_none('start_range', start_range)44 if end_range_required:45 _validate_not_none('end_range', end_range)46 # Format based on whether end_range is present47 request.headers = request.headers or {}48 if end_range is not None:49 request.headers['x-ms-range'] = 'bytes={0}-{1}'.format(start_range, end_range)50 elif start_range is not None:51 request.headers['x-ms-range'] = 'bytes={0}-'.format(start_range)52 # Content MD5 can only be provided for a complete range less than 4MB in size53 if check_content_md5:54 if start_range is None or end_range is None:55 raise ValueError(_ERROR_START_END_NEEDED_FOR_MD5)56 if end_range - start_range > 4 * 1024 * 1024:57 raise ValueError(_ERROR_RANGE_TOO_LARGE_FOR_MD5)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful