本文整理汇总了Python中asposecloud.common.Utils.upload_file_binary方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.upload_file_binary方法的具体用法?Python Utils.upload_file_binary怎么用?Python Utils.upload_file_binary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asposecloud.common.Utils
的用法示例。
在下文中一共展示了Utils.upload_file_binary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_from_local_image
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import upload_file_binary [as 别名]
def read_from_local_image(local_image, symbology):
"""
Read barcode from local image
:param local_image:
:param symbology:
:return: Text of barcode
"""
if not local_image:
raise ValueError("local_image not specified")
filename = os.path.basename(local_image)
str_uri = Product.product_uri + 'storage/file/' + filename
signed_uri = Utils.sign(str_uri)
Utils.upload_file_binary(local_image, signed_uri)
str_uri = Product.product_uri + 'barcode/' + filename + '/recognize'
if symbology:
str_uri += '?type=' + symbology
signed_uri = Utils.sign(str_uri)
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}).json()
return response['Barcodes'] if response['Code'] == 200 else False
示例2: upload_file
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import upload_file_binary [as 别名]
def upload_file(self, local_file, remote_folder='', storage_type='Aspose', storage_name=None):
"""
Upload a local file to cloud storage.
:param local_file:
:param remote_folder: storage path to operate
:param storage_type: type of storage e.g Aspose, S3
:param storage_name: name of storage e.g. MyAmazonS3
:return: returns True or False
"""
if not local_file:
raise ValueError("local_file not specified.")
filename = os.path.basename(local_file)
str_uri = self.str_uri_file
if remote_folder:
str_uri = str_uri + remote_folder + '/'
str_uri += filename
str_uri = Utils.append_storage(str_uri, '', storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = Utils.upload_file_binary(local_file, signed_uri).json()
if response['Status'] == 'OK':
return True
else:
return False
示例3: convert_local_file
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import upload_file_binary [as 别名]
def convert_local_file(input_file, save_format, stream_out=False, output_filename=None):
"""
Convert a local pdf file to any supported format
:param input_file:
:param save_format:
:param stream_out:
:param output_filename:
:return:
"""
if not input_file:
raise ValueError("input_file not specified")
if not save_format:
raise ValueError("save_format not specified")
str_uri = Product.product_uri + 'slides/convert?format=' + save_format
signed_uri = Utils.sign(str_uri)
response = None
try:
response = Utils.upload_file_binary(input_file, signed_uri)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
if not stream_out:
if output_filename is None:
output_filename = input_file
save_format = 'zip' if save_format == 'html' else save_format
output_path = AsposeApp.output_path + Utils.get_filename(output_filename) + '.' + save_format
Utils.save_file(response, output_path)
return output_path
else:
return response.content