You are here

public function FileApi::uploadFile in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 vendor/smartling/api-sdk-php/src/File/FileApi.php \Smartling\File\FileApi::uploadFile()
  2. 8.2 api-sdk-php/src/File/FileApi.php \Smartling\File\FileApi::uploadFile()
  3. 8.2 vendor/smartling/api-sdk-php/src/File/FileApi.php \Smartling\File\FileApi::uploadFile()

Uploads original source content to Smartling.

Parameters

string $realPath: Real path to the file to read in into stream.

string $file_name: Value that uniquely identifies the uploaded file. This ID can be used to request the file back.

string $file_type: Unique identifier for the file type. Permitted values: android, ios, gettext, html, javaProperties, yaml, xliff, xml, json, docx, pptx, xlsx, idml, qt, resx, plaintext, cvs, stringsdict.

UploadFileParameters $params: (optional) An associative array of additional options, with the following elements:

  • 'approved': Determines whether content in the file is authorized (available for translation) upon submitting the file via the Smartling Dashboard.
  • 'localesToApprove': This value, if set, authorizes strings for translation into specific locales.

Return value

array Data about uploaded file.

Throws

\Smartling\Exceptions\SmartlingApiException

See also

http://docs.smartling.com/pages/API/FileAPI/Upload-File/

File

vendor/smartling/api-sdk-php/src/File/FileApi.php, line 89

Class

FileApi
Class FileApi

Namespace

Smartling\File

Code

public function uploadFile($realPath, $file_name, $file_type, UploadFileParameters $params = null) {
  if (is_null($params)) {
    $params = new UploadFileParameters();
  }
  $params = $params
    ->exportToArray();
  $params['file'] = $realPath;
  $params['fileUri'] = $file_name;
  $params['fileType'] = $file_type;
  $requestData = $this
    ->getDefaultRequestData('multipart', $params);
  return $this
    ->sendRequest('file', $requestData, self::HTTP_METHOD_POST);
}