Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.1
---

* Add a download link in mailer profiler for email attachments

5.4
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@
<div class="tab">
<h3 class="tab-title">Attachment #{{ loop.index }}</h3>
<div class="tab-content">
<p>
<a href="data:{{ attachment.contentType|default('application/octet-stream') }};base64,{{ collector.base64Encode(attachment.body) }}" download="{{ attachment.filename|default('attachment') }}">
{% if attachment.filename|default %}
{{ attachment.filename }}
{% else %}
<em>(no filename)</em>
{% endif %}
</a>
</p>
<pre class="prewrap" style="max-height: 600px">{{ attachment.toString() }}</pre>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Mime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.1
---

* Add `DataPart::getFilename()` and `DataPart::getContentType()`

6.0
---

Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Component/Mime/Part/DataPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ public function asDebugString(): string
return $str;
}

public function getFilename(): ?string
{
return $this->filename;
}

public function getContentType(): string
{
return implode('/', [$this->getMediaType(), $this->getMediaSubtype()]);
}

private function generateContentId(): string
{
return bin2hex(random_bytes(16)).'@symfony';
Expand Down
18 changes: 18 additions & 0 deletions src/Symfony/Component/Mime/Tests/Part/DataPartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ public function testHasContentId()
$this->assertTrue($p->hasContentId());
}

public function testGetFilename()
{
$p = new DataPart('content', null);
self::assertNull($p->getFilename());

$p = new DataPart('content', 'filename');
self::assertSame('filename', $p->getFilename());
}

public function testGetContentType()
{
$p = new DataPart('content');
self::assertSame('application/octet-stream', $p->getContentType());

$p = new DataPart('content', null, 'application/pdf');
self::assertSame('application/pdf', $p->getContentType());
}

public function testSerialize()
{
$r = fopen('php://memory', 'r+', false);
Expand Down