You are here

public function BatchApi::uploadBatchFile in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 vendor/smartling/api-sdk-php/src/Batch/BatchApi.php \Smartling\Batch\BatchApi::uploadBatchFile()

Uploads file.

Parameters

$realPath:

$fileName:

$fileType:

$batchUid:

UploadFileParameters $parameters:

Return value

bool

Throws

SmartlingApiException

File

vendor/smartling/api-sdk-php/src/Batch/BatchApi.php, line 90

Class

BatchApi
Class JobsFacadeApi

Namespace

Smartling\Batch

Code

public function uploadBatchFile($realPath, $fileName, $fileType, $batchUid, UploadFileParameters $parameters = null) {

  // @TODO: let's pass file, fileUri and fileType in UploadFileParameters.
  // In this case we could get rid of passing these variables into this
  // method. But this approach requires changes in UploadFileParameters
  // class + changes in FileApi::uploadFile() method.
  if (is_null($parameters)) {
    $parameters = new UploadFileParameters();
  }
  $parameters = $parameters
    ->exportToArray();
  $parameters['file'] = $realPath;
  $parameters['fileUri'] = $fileName;
  $parameters['fileType'] = $fileType;
  $endpoint = vsprintf('batches/%s/file', [
    $batchUid,
  ]);
  $requestData = $this
    ->getDefaultRequestData('multipart', $parameters);
  return $this
    ->sendRequest($endpoint, $requestData, self::HTTP_METHOD_POST);
}