if (!
$this->fileSystem->
prepareDirectory($destination, FileSystemInterface::CREATE_DIRECTORY
)) { throw new HttpException(500, 'Destination file path is not writable'
);
} $validators =
$this->
getUploadValidators($field_definition);
$prepared_filename =
$this->
prepareFilename($filename,
$validators);
// Create the file.
$file_uri = "{
$destination}/{
$prepared_filename}";
$temp_file_path =
$this->
streamUploadData();
$file_uri =
$this->fileSystem->
getDestinationFilename($file_uri, FileSystemInterface::EXISTS_RENAME
);
// Lock based on the prepared file URI.
$lock_id =
$this->
generateLockIdFromFileUri($file_uri);
if (!
$this->lock->
acquire($lock_id)) { throw new HttpException(503,
sprintf('File "%s" is already locked for writing',
$file_uri), NULL,
['Retry-After' => 1
]);
} // Begin building file entity.