/**
  * Creates FileResult object from the response of the file request.
  *
  * @param array $headers The HTTP response headers in array representation.
  *
  * @return FileResult
  */
 public static function create($headers)
 {
     $result = new FileResult();
     $result->setETag(Utilities::tryGetValueInsensitive(Resources::ETAG, $headers));
     if (Utilities::arrayKeyExistsInsensitive(Resources::LAST_MODIFIED, $headers)) {
         $lastModified = Utilities::tryGetValueInsensitive(Resources::LAST_MODIFIED, $headers);
         $result->setLastModified(Utilities::rfc1123ToDateTime($lastModified));
     }
     return $result;
 }
 /**
  * Creates a new file.
  *
  * @param string                   $share         The share name.
  * @param string                   $directoryPath The directory path.
  * @param string                   $file          The name of file
  * @param integer                  $length        Specifies the maximum size for the
  *                                                file, up to 1 TB. The file size must be aligned to a 512-byte
  *                                                boundary.
  * @param Models\CreateFileOptions $options       The optional parameters.
  *
  * @return FileResult
  *
  * @see https://msdn.microsoft.com/en-us/library/azure/dn194271.aspx
  */
 public function createFile($share, $directoryPath, $file, $length, $options = null)
 {
     Validate::isString($share, 'share');
     Validate::isString($directoryPath, 'directoryPath');
     Validate::isString($file, 'file');
     Validate::isInteger($length, 'length');
     Validate::notNull($length, 'length');
     $method = Resources::HTTP_PUT;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $this->_createPath($share, $directoryPath, $file);
     $statusCode = Resources::STATUS_CREATED;
     if (is_null($options)) {
         $options = new CreateFileOptions();
     }
     $headers[Resources::X_MS_TYPE] = Resources::FILE_TYPE;
     $headers[Resources::X_MS_CONTENT_LENGTH] = $length;
     $headers = $this->_addCreateFileOptionalHeaders($options, $headers);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
     return FileResult::create($response->getHeader());
 }