Skip to content

Commit

Permalink
[WebProfilerBundle] Display uploaded files in the profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz authored and fabpot committed Jun 25, 2018
1 parent c442929 commit 3f6f75b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Expand Up @@ -131,6 +131,33 @@
{{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestrequest, maxDepth: 1 }, with_context = false) }}
{% endif %}

<h3>Uploaded files</h3>

{% if collector.requestfiles is empty %}
<div class="empty">
<p>No files were uploaded</p>
</div>
{% else %}
<table>
<thead>
<tr>
<th scope="col">File Name</th>
<th scope="col">MIME Type</th>
<th scope="col text-right">Size (bytes)</th>
</tr>
</thead>
<tbody>
{% for file in collector.requestfiles %}
<tr>
<td>{{ file.name }}</td>
<td>{{ file.mimetype }}</td>
<td class="text-right">{{ file.size|number_format }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}

<h3>Request Attributes</h3>

{% if collector.requestattributes.all is empty %}
Expand Down
Expand Up @@ -57,6 +57,17 @@ public function collect(Request $request, Response $response, \Exception $except
$content = false;
}

$requestFiles = array();
foreach ($request->files->all() as $files) {
foreach ($files as $fileName => $fileData) {
$requestFiles[] = array(
'name' => $fileData->getClientOriginalName(),
'mimetype' => $fileData->getMimeType(),
'size' => $fileData->getSize(),
);
}
}

$sessionMetadata = array();
$sessionAttributes = array();
$session = null;
Expand Down Expand Up @@ -95,6 +106,7 @@ public function collect(Request $request, Response $response, \Exception $except
'status_code' => $statusCode,
'request_query' => $request->query->all(),
'request_request' => $request->request->all(),
'request_files' => $requestFiles,
'request_headers' => $request->headers->all(),
'request_server' => $request->server->all(),
'request_cookies' => $request->cookies->all(),
Expand Down Expand Up @@ -195,6 +207,11 @@ public function getRequestQuery()
return new ParameterBag($this->data['request_query']->getValue());
}

public function getRequestFiles()
{
return $this->data['request_files']->getValue(true);
}

public function getRequestHeaders()
{
return new ParameterBag($this->data['request_headers']->getValue());
Expand Down

0 comments on commit 3f6f75b

Please sign in to comment.