Sha256: cdf4d866be320dc45a7c0d7777caf4a70effd0729c82922d087ef7acab24e16f
Contents?: true
Size: 1.09 KB
Versions: 19
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Aws::Translate module Plugins # @api private # The translated_documented returned by the translate_document api is modeled # as a blob, since it may contain binary data (eg: word doc). However, # when the input document is text (eg: text/plain or text/html) the encoding # should be preserved. class TranslateDocumentEncoding < Seahorse::Client::Plugin class Handler < Seahorse::Client::Handler def call(context) # detect encoding document = context.params[:document] encoding = if document[:content_type].start_with?('text/') && document[:content].is_a?(String) document[:content].encoding end resp = @handler.call(context) if encoding resp.translated_document.content = resp.translated_document.content.force_encoding(encoding) end resp end end def add_handlers(handlers, _config) handlers.add(Handler, step: :initialize, operations: [:translate_document]) end end end end
Version data entries
19 entries across 19 versions & 1 rubygems