本文整理汇总了Python中asposecloud.common.Utils.get_filename方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.get_filename方法的具体用法?Python Utils.get_filename怎么用?Python Utils.get_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asposecloud.common.Utils
的用法示例。
在下文中一共展示了Utils.get_filename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def convert(self, save_format, additional_params=None, slide_number=None, stream_out=False, output_filename=None,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param save_format:
:param additional_params:
:param slide_number:
:param stream_out:
:param output_filename:
: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:
"""
if not save_format:
raise ValueError("save_format not specified")
str_uri = self.base_uri + '/slides'
if(slide_number):
str_uri += '/' + str(slide_number)
qry_str = {'format': save_format}
if(additional_params):
qry_str.update(additional_params)
str_uri = Utils.build_uri(str_uri, qry_str)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
if not stream_out:
if output_filename is None:
output_filename = self.filename
save_format = 'zip' if save_format == 'html' else save_format
if(slide_number):
output_path = AsposeApp.output_path + Utils.get_filename(output_filename) + '_' + str(slide_number) + '.' + \
save_format
else:
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
else:
return validate_output
示例2: extract_frame
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def extract_frame(self, frame_id, remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param frame_id:
: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:
"""
str_uri = self.base_uri + '/frames/' + str(frame_id) + '?saveOtherFrames=false'
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '_frame_' + str(frame_id) + '.tiff'
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
return response
示例3: update_tiff_properties
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def update_tiff_properties(self, bit_depth, compression, resolution_unit, new_width, new_height,
horizontal_resolution, vertical_resolution, output_path,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param bit_depth:
:param compression:
:param resolution_unit:
:param new_width:
:param new_height:
:param horizontal_resolution:
:param vertical_resolution:
:param output_path:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = Product.product_uri + 'storage/file/' + self.filename
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
file_content = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json'
}, stream=True)
str_uri = Product.product_uri + 'imaging/tiff'
qry = {'compression': compression, 'resolutionUnit': resolution_unit, 'newWidth' : new_width,
'newHeight' : new_height, 'horizontalResolution' : horizontal_resolution,
'verticalResolution' : vertical_resolution, 'bitDepth' : bit_depth, 'outputPath': output_path}
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.post(signed_uri, file_content, headers={
'content-type': 'application/json', 'accept': 'application/json'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '_updated.tiff'
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
示例4: get_image
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def get_image(self, page_number, image_index, save_format, width=None, height=None,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
Get image from given page
:param page_number:
:param image_index:
:param save_format:
:param width:
:param height:
: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:
"""
if not save_format:
raise ValueError("save_format not specified")
if not page_number:
raise ValueError("page_number not specified")
str_uri = self.base_uri + '/pages/' + str(page_number) + '/images/' + str(image_index)
qry = {'format': save_format}
if width and height:
qry['width'] = width
qry['height'] = height
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '_' + str(page_number) \
+ '_' + str(image_index) + '.' + save_format
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
示例5: crop_tiff_frame
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def crop_tiff_frame(self, frame_id, x, y, new_width, new_height, output_path,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param frame_id:
:param x:
:param y:
:param new_width:
:param new_height:
:param output_path:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = Product.product_uri + 'imaging/' + self.filename + '/frames/' + str(frame_id)
qry = {'saveOtherFrames': True, 'x':x, 'y':y, 'newWidth': new_width, 'newHeight': new_height,
'outputPath': output_path}
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
save_format = 'tiff'
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '_croped_frame_' + \
str(frame_id) + '.' + save_format
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
示例6: create_pdf
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def create_pdf(self, template_file, source_format, stream_out=False, output_filename=None,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
Create a pdf file from any supported format file e.g. html,xml,jpeg,svg,tiff
:param template_file:
:param source_format:
:param stream_out:
:param output_filename:
: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:
"""
if not template_file:
raise ValueError("template_file not specified")
if not source_format:
raise ValueError("source_format not specified")
save_format = 'pdf'
str_uri = self.base_uri + '?templateFile=' + template_file + '&templateType=' + source_format
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.put(signed_uri, None, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
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 = self.filename
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
示例7: resize_image
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def resize_image(self, input_file_path, new_width, new_height, output_filename, save_format,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param input_file_path:
:param new_width:
:param new_height:
:param output_filename:
:param save_format:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = Product.product_uri + 'imaging/resize'
qry = {'newWidth': new_width, 'newHeight': new_height, 'format': save_format}
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
with open(input_file_path, 'rb') as payload:
response = requests.post(signed_uri, data=payload, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
save_format = 'zip' if save_format == 'html' else save_format
output_path = AsposeApp.output_path + Utils.get_filename(input_file_path) + '.' + save_format
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
示例8: convert_local_file
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def convert_local_file(self, input_file_path, save_format, stream_out=False, output_filename=None,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param input_file_path:
:param save_format:
:param stream_out:
:param output_filename:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = Product.product_uri + 'imaging/' + self.filename + '/saveAs?format=' + save_format
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
with open(input_file_path, 'rb') as payload:
response = requests.get(signed_uri, data=payload, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
if not stream_out:
if output_filename is None:
output_filename = input_file_path
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
else:
return validate_output
示例9: crop_image
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def crop_image(self, x, y, width, height, output_path, save_format,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param x:
:param y:
:param width:
:param height:
:param output_path:
:param save_format:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = Product.product_uri + 'imaging/' + self.filename + '/crop'
qry = {'x': x, 'y': y, 'width': width, 'height': height, 'outputPath': output_path, 'format': save_format}
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
save_format = 'zip' if save_format == 'html' else save_format
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '_croped.' + save_format
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
示例10: update_gif_properties_local
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def update_gif_properties_local(self, input_file_path, bg_color_index, px_aspect_ratio, interlaced,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param input_file_path:
:param bg_color_index:
:param px_aspect_ratio:
:param interlaced:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = Product.product_uri + 'imaging/gif'
qry = {'backgroundColorIndex': bg_color_index, 'pixelAspectRatio': px_aspect_ratio,
'interlaced': interlaced}
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
with open(input_file_path, 'rb') as payload:
response = requests.post(signed_uri, data=payload, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '_updated.gif'
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
示例11: update_bmp_properties
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def update_bmp_properties(self, bits_per_px, h_resolution, v_resolution, output_path,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param bits_per_px:
:param h_resolution:
:param v_resolution:
:param output_path:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = self.base_uri + '/bmp'
qry = {'bitsPerPixel': bits_per_px, 'horizontalResolution': h_resolution,
'verticalResolution': v_resolution,'outputPath': output_path}
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '_updated.bmp'
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
示例12: update_jpg_properties_local
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def update_jpg_properties_local(self, input_file_path, quality, compression_type,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param input_file_path:
:param quality:
:param compression_type:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = Product.product_uri + 'imaging/jpg'
qry = {'quality': quality, 'compressionType': compression_type}
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
with open(input_file_path, 'rb') as payload:
response = requests.post(signed_uri, data=payload, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '_updated.jpg'
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
示例13: update_psd_properties
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def update_psd_properties(self, channels_count, compression_method, output_path,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param channels_count:
:param compression_method:
:param output_path:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = self.base_uri + '/psd'
qry = {'channelsCount': channels_count, 'compressionMethod': compression_method,
'outputPath': output_path}
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '_updated.psd'
Utils.save_file(response, output_path)
return output_path
else:
return validate_output
示例14: convert
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def convert(self, save_format, stream_out=False, output_filename=None,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
convert an email message document to a different format
:param save_format:
:param output_filename:
: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:
"""
if not save_format:
raise ValueError("save_format not specified")
str_uri = self.base_uri + '?format=' + save_format
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
if not stream_out:
if output_filename is None:
output_filename = self.filename
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
else:
return validate_output
示例15: rotate_image
# 需要导入模块: from asposecloud.common import Utils [as 别名]
# 或者: from asposecloud.common.Utils import get_filename [as 别名]
def rotate_image(self, method, output_path, save_format,
remote_folder='', storage_type='Aspose', storage_name=None):
"""
:param method:
:param output_path:
:param save_format:
:param remote_folder:
:param storage_type:
:param storage_name:
:return:
"""
str_uri = Product.product_uri + 'imaging/' + self.filename + '/rotateflip'
qry = {'method': method, 'outputPath': output_path, 'format': save_format}
str_uri = Utils.build_uri(str_uri, qry)
str_uri = Utils.append_storage(str_uri, remote_folder, storage_type, storage_name)
signed_uri = Utils.sign(str_uri)
response = None
try:
response = requests.get(signed_uri, headers={
'content-type': 'application/json', 'accept': 'application/json', 'x-aspose-client' : 'PYTHONSDK/v1.0'
}, stream=True)
response.raise_for_status()
except requests.HTTPError as e:
print e
print response.content
exit(1)
validate_output = Utils.validate_result(response)
if not validate_output:
save_format = 'zip' if save_format == 'html' else save_format
output_path = AsposeApp.output_path + Utils.get_filename(self.filename) + '.' + save_format
Utils.save_file(response, output_path)
return output_path
else:
return validate_output