Class: Aspose::Cloud::Words::Converter
- Inherits:
-
Object
- Object
- Aspose::Cloud::Words::Converter
- Defined in:
- lib/Words/converter.rb
Instance Method Summary collapse
- #convert(save_format, storage_name = '', folder = '') ⇒ Object
- #convert_local_file(input_path, output_path, output_format) ⇒ Object
-
#initialize(filename) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(filename) ⇒ Converter
Returns a new instance of Converter.
8 9 10 |
# File 'lib/Words/converter.rb', line 8 def initialize filename @filename = filename end |
Instance Method Details
#convert(save_format, storage_name = '', folder = '') ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/Words/converter.rb', line 12 def convert save_format, storage_name='', folder='' begin if(@filename == '') raise('Filename cannot be empty.') end if(storage_name.empty? == true) str_uri = $product_uri + '/words/' + @filename + '?format=' + save_format else str_uri = $product_uri + '/words/' + @filename + '?format=' + save_format + '&storage='+storage_name+'&folder='+folder end signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = RestClient.get(signed_str_uri,{:accept=>'application/json'}) valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if valid_output == '' output_path = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + save_format Aspose::Cloud::Common::Utils.save_file(response_stream,output_path) return '' else return valid_output end rescue Exception=>e print e end end |
#convert_local_file(input_path, output_path, output_format) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/Words/converter.rb', line 44 def convert_local_file input_path,output_path,output_format begin if input_path=='' raise 'Input File Name not specified' end if output_path == '' raise 'Please Specify Output Path' end if output_format == '' raise 'Please Specify Output Format' end str_uri =$product_uri + '/words/convert?format=' + output_format signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response_stream = Aspose::Cloud::Common::Utils.upload_file_binary(input_path, signed_uri) v_output = Aspose::Cloud::Common::Utils.validate_output(response_stream) if v_output == '' if output_format == 'html' save_format = 'zip' else save_format = output_format end output_file = $out_put_location + Aspose::Cloud::Common::Utils.get_filename(input_path) + '.' + save_format Aspose::Cloud::Common::Utils.save_file(response_stream, output_file) return output_file else return v_output end rescue Exception => e print e end end |