Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Output filename for Translate Document API

Hello,

I have been developing an iOS mobile app to translate PDF documents and currently using Google Translate documents API without any issue.

Is there any way, we can update or change the output filename coming from the API? Currently, the output file name includes all the attributes starting from the project name, bucket name and finally the file name. This won't be appropriate for the users to showcase these things.

Is there any configuration to change this filename to more user friendly format?

e.g. Input file name - Test_Translation_En_Fr_Sp.pdf

Output filename from Translate API -scantranslatorapp.appspot.com_uploaded_documents_FuOrb0L4tudAZvhZ99IwsFYg83M2_Test_Translation_En_Fr_Sp_fr_translations.pdf

It would be appropriate to showcase only - Test_Translation_En_Fr_Sp_fr_translations.pdf

0 1 403
1 REPLY 1

You can change the output file prefix for this you need to do a REST request to the as a POST to the API URL:

https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument

With the following request JSON body:

{
  "source_language_code": "SOURCE_LANGUAGE",
  "target_language_code": "TARGET_LANGUAGE",
  "document_input_config": {
    "mimeType": "MIME_TYPE",
    "content": "INPUT_BYTE_STREAM"
  },
  "document_output_config": {
    "gcsDestination": {
      "outputUriPrefix": "gs://OUTPUT_FILE_PREFIX"
    }
  }
}