diff --git a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php index a3d3e18be4..1a954e5b40 100644 --- a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php +++ b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php @@ -3,6 +3,7 @@ namespace Drupal\file\Plugin\rest\resource; use Drupal\Component\Plugin\DependentPluginInterface; +use Drupal\rest\ModifiedResourceResponse; use Drupal\rest\Plugin\ResourceBase; use Drupal\Component\Render\PlainTextOutput; use Drupal\Core\Entity\EntityFieldManagerInterface; @@ -153,7 +154,7 @@ public function post(Request $request, $entity_type_id, $bundle, $field_name) { $file->save(); - return $file; + return new ModifiedResourceResponse($file, 201); } /** @@ -178,7 +179,7 @@ protected function streamUploadData($destination_uri) { // Move the file to the correct location based on the file entity, // replacing any existing file. - if (!file_unmanaged_move($temp_file_name, $uri, FILE_EXISTS_REPLACE)) { + if (!file_unmanaged_move($temp_file_name, $destination_uri, FILE_EXISTS_REPLACE)) { throw new HttpException(500, 'Temporary file could not be moved to file location'); } }