/**
  * Create new blank file in cloud service.
  * It is not necessary set shared rights on file.
  * @param FileData $fileData
  * @return FileData|null
  */
 public function createBlankFile(FileData $fileData)
 {
     if (!$this->checkRequiredInputParams($fileData->toArray(), array('name'))) {
         return null;
     }
     $accessToken = $this->getAccessToken();
     $googleMimeType = $this->getInternalMimeTypeByExtension(getFileExtension($fileData->getName()));
     $fileName = getFileNameWithoutExtension($fileData->getName());
     $fileName = $this->convertToUtf8($fileName);
     if (!$googleMimeType) {
         $this->errorCollection->add(array(new Error("Unsupported file format with name {$fileData->getName()}", self::ERROR_UNSUPPORTED_FILE_FORMAT)));
         return null;
     }
     $http = new HttpClient(array('socketTimeout' => 10, 'streamTimeout' => 30, 'version' => HttpClient::HTTP_1_1));
     $http->setHeader('Content-Type', 'application/json; charset=UTF-8');
     $http->setHeader('Authorization', "Bearer {$accessToken}");
     $postFields = "{\"title\":\"{$fileName}\",\"mimeType\":\"{$googleMimeType}\"}";
     if ($http->post(self::API_URL_V2 . '/files', $postFields) === false) {
         $errorString = implode('; ', array_keys($http->getError()));
         $this->errorCollection->add(array(new Error($errorString, self::ERROR_HTTP_CREATE_BLANK)));
         return null;
     }
     if (!$this->checkHttpResponse($http)) {
         return null;
     }
     $finalOutput = Json::decode($http->getResult());
     if ($finalOutput === null) {
         $this->errorCollection->add(array(new Error('Could not decode response as json', self::ERROR_BAD_JSON)));
         return null;
     }
     if (empty($finalOutput['id']) || empty($finalOutput['alternateLink'])) {
         $this->errorCollection->add(array(new Error('Could not find id or alternateLink in response from Google.', self::ERROR_COULD_NOT_FIND_ID)));
         return null;
     }
     $fileData->setLinkInService($finalOutput['alternateLink']);
     $fileData->setId($finalOutput['id']);
     //last signed user must delete file from google drive
     $this->insertPermission($fileData);
     return $fileData;
 }