lib/filestack/utils/multipart_upload_utils.rb in filestack-2.6.3 vs lib/filestack/utils/multipart_upload_utils.rb in filestack-2.6.4

- old
+ new

@@ -43,20 +43,21 @@ # policy/signature # @param [Hash] options User-defined options for # multipart uploads # # @return [Typhoeus::Response] - def multipart_start(apikey, filename, filesize, mimetype, security, storage, options = {}) + def multipart_start(apikey, filename, filesize, mimetype, security, storage, options = {}, intelligent) params = { apikey: apikey, filename: filename, mimetype: mimetype, size: filesize, store_location: storage, file: Tempfile.new(filename), - 'multipart' => 'true' + multipart: intelligent } + options = multipart_options(options) params = params.merge!(options) if options unless security.nil? params[:policy] = security.policy @@ -202,39 +203,24 @@ # @param [Hash] options User-defined options for # multipart uploads # # @return [Typhoeus::Response] def multipart_complete(apikey, filename, filesize, mimetype, start_response, parts_and_etags, options, storage, intelligent = false) - if !intelligent - data = { - apikey: apikey, - uri: start_response['uri'], - region: start_response['region'], - upload_id: start_response['upload_id'], - filename: filename, - size: filesize, - mimetype: mimetype, - parts: parts_and_etags.join(';'), - store_location: storage, - file: Tempfile.new(filename) - } - else - data = { - apikey: apikey, - uri: start_response['uri'], - region: start_response['region'], - upload_id: start_response['upload_id'], - filename: filename, - size: filesize, - mimetype: mimetype, - store_location: storage, - file: Tempfile.new(filename), - 'multipart' => 'true' - } - end + data = { + apikey: apikey, + uri: start_response['uri'], + region: start_response['region'], + upload_id: start_response['upload_id'], + filename: filename, + size: filesize, + mimetype: mimetype, + store_location: storage, + file: Tempfile.new(filename) + } options = multipart_options(options) - data = data.merge!(options) if options + data.merge!(options) if options + data.merge!(intelligent ? { multipart: intelligent } : { parts: parts_and_etags.join(';') }) Typhoeus.post( FilestackConfig::MULTIPART_COMPLETE_URL, body: data, headers: FilestackConfig::HEADERS ) @@ -251,10 +237,10 @@ # # @return [Hash] def multipart_upload(apikey, filepath, security, options, timeout, storage, intelligent: false) filename, filesize, mimetype = get_file_info(filepath) start_response = multipart_start( - apikey, filename, filesize, mimetype, security, storage, options + apikey, filename, filesize, mimetype, security, storage, options, intelligent ) unless start_response['upload_type'].nil? intelligent_enabled = ((start_response['upload_type'].include? 'intelligent_ingestion')) && intelligent end