Issue #3402981 by kim.pepper, larowlan, quietone: Filename property is not updated when a duplicate file is renamed In REST and JSON API file uploads
parent
89ec081a50
commit
501e1ed2fb
|
@ -330,6 +330,12 @@ class FileUploadResource extends ResourceBase {
|
|||
}
|
||||
|
||||
$file->setFileUri($file_uri);
|
||||
// Update the filename with any changes as a result of security or renaming
|
||||
// due to an existing file.
|
||||
// @todo Remove this duplication by replacing with FileUploadHandler. See
|
||||
// https://www.drupal.org/project/drupal/issues/3401734
|
||||
$file->setFilename($this->fileSystem->basename($file->getFileUri()));
|
||||
|
||||
// Move the file to the correct location after validation. Use
|
||||
// FileSystemInterface::EXISTS_ERROR as the file location has already been
|
||||
// determined above in FileSystem::getDestinationFilename().
|
||||
|
|
|
@ -245,6 +245,13 @@ class TemporaryJsonapiFileFieldUploader {
|
|||
}
|
||||
|
||||
$file->setFileUri($file_uri);
|
||||
|
||||
// Update the filename with any changes as a result of security or renaming
|
||||
// due to an existing file.
|
||||
// @todo Remove this duplication by replacing with FileUploadHandler. See
|
||||
// https://www.drupal.org/project/drupal/issues/3401734
|
||||
$file->setFilename($this->fileSystem->basename($file->getFileUri()));
|
||||
|
||||
// Move the file to the correct location after validation. Use
|
||||
// FileSystemInterface::EXISTS_ERROR as the file location has already been
|
||||
// determined above in FileSystem::getDestinationFilename().
|
||||
|
|
|
@ -249,7 +249,7 @@ class FileUploadTest extends ResourceTestBase {
|
|||
// header with no 'file' prefix.
|
||||
$response = $this->fileRequest($uri, $this->testFileData, ['Content-Disposition' => 'filename="example.txt"']);
|
||||
$this->assertSame(201, $response->getStatusCode());
|
||||
$expected = $this->getExpectedDocument(2, 'example_0.txt');
|
||||
$expected = $this->getExpectedDocument(2, 'example_0.txt', TRUE);
|
||||
$this->assertResponseData($expected, $response);
|
||||
|
||||
// Check the actual file data.
|
||||
|
@ -340,7 +340,7 @@ class FileUploadTest extends ResourceTestBase {
|
|||
'data' => [
|
||||
0 => $this->getExpectedDocument(1, 'existing.txt', TRUE, TRUE)['data'],
|
||||
1 => $this->getExpectedDocument(2, 'example.txt', TRUE, TRUE)['data'],
|
||||
2 => $this->getExpectedDocument(3, 'example_0.txt', FALSE, TRUE)['data'],
|
||||
2 => $this->getExpectedDocument(3, 'example_0.txt', TRUE, TRUE)['data'],
|
||||
],
|
||||
];
|
||||
$this->assertResponseData($expected, $response);
|
||||
|
@ -448,7 +448,7 @@ class FileUploadTest extends ResourceTestBase {
|
|||
$this->assertSame(201, $response->getStatusCode());
|
||||
|
||||
// Loading expected normalized data for file 2, the duplicate file.
|
||||
$expected = $this->getExpectedDocument(2, 'example_0.txt');
|
||||
$expected = $this->getExpectedDocument(2, 'example_0.txt', TRUE);
|
||||
$this->assertResponseData($expected, $response);
|
||||
|
||||
// Check the actual file data.
|
||||
|
|
|
@ -195,7 +195,7 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
|
|||
// header with no 'file' prefix.
|
||||
$response = $this->fileRequest($uri, $this->testFileData, ['Content-Disposition' => 'filename="example.txt"']);
|
||||
$this->assertSame(201, $response->getStatusCode());
|
||||
$expected = $this->getExpectedNormalizedEntity(2, 'example_0.txt');
|
||||
$expected = $this->getExpectedNormalizedEntity(2, 'example_0.txt', TRUE);
|
||||
$this->assertResponseData($expected, $response);
|
||||
|
||||
// Check the actual file data.
|
||||
|
@ -317,7 +317,7 @@ abstract class FileUploadResourceTestBase extends ResourceTestBase {
|
|||
$this->assertSame(201, $response->getStatusCode());
|
||||
|
||||
// Loading expected normalized data for file 2, the duplicate file.
|
||||
$expected = $this->getExpectedNormalizedEntity(2, 'example_0.txt');
|
||||
$expected = $this->getExpectedNormalizedEntity(2, 'example_0.txt', TRUE);
|
||||
$this->assertResponseData($expected, $response);
|
||||
|
||||
// Check the actual file data.
|
||||
|
|
Loading…
Reference in New Issue