// Enable the 'file_upload' REST resource for the current format + auth.
$this->resourceConfigStorage->
create([ 'id' => 'file.upload',
'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY,
'configuration' =>
[ 'methods' =>
['POST'
],
'formats' =>
[static::
$format],
'authentication' =>
isset(static::
$auth) ?
[static::
$auth] :
[],
],
'status' => TRUE,
])->
save();
$this->
refreshTestStateAfterRestConfigChange();
$this->
initAuthentication();
// POST to create a File entity.
$url = Url::
fromUri('base:file/upload/media/camelids/field_media_file'
);
$url->
setOption('query',
['_format' =>
static::
$format]);
$request_options =
[];
$request_options[RequestOptions::HEADERS
] =
[ // Set the required (and only accepted) content type for the request.
'Content-Type' => 'application/octet-stream',
// Set the required Content-Disposition header for the file name.