aboutsummaryrefslogtreecommitdiff
path: root/External/swiftmailer/lib/classes/Swift/Mime/Attachment.php
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2021-10-15 09:52:00 +1100
committerYuchen Pei <hi@ypei.me>2021-10-15 09:52:00 +1100
commit71b0e901f5fb1cfcd162d8acc23120d3f77a3152 (patch)
tree323c00faef1edc7dea2e88ff581cc2258b2b6432 /External/swiftmailer/lib/classes/Swift/Mime/Attachment.php
parent72cce24864b064b5762f4fe97fdf40d8d2ad4b51 (diff)
parent07f5140771388c9e0c8a99b0dd2e5d950bdb173b (diff)
Merge branch 'development' into h-node
Diffstat (limited to 'External/swiftmailer/lib/classes/Swift/Mime/Attachment.php')
-rwxr-xr-xExternal/swiftmailer/lib/classes/Swift/Mime/Attachment.php143
1 files changed, 143 insertions, 0 deletions
diff --git a/External/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/External/swiftmailer/lib/classes/Swift/Mime/Attachment.php
new file mode 100755
index 0000000..25ef68b
--- /dev/null
+++ b/External/swiftmailer/lib/classes/Swift/Mime/Attachment.php
@@ -0,0 +1,143 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+//@require 'Swift/Mime/SimpleMimeEntity.php';
+//@require 'Swift/Mime/ContentEncoder.php';
+//@require 'Swift/Mime/HeaderSet.php';
+//@require 'Swift/FileStream.php';
+//@require 'Swift/KeyCache.php';
+
+/**
+ * An attachment, in a multipart message.
+ * @package Swift
+ * @subpackage Mime
+ * @author Chris Corbyn
+ */
+class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity
+{
+
+ /** Recognized MIME types */
+ private $_mimeTypes = array();
+
+ /**
+ * Create a new Attachment with $headers, $encoder and $cache.
+ * @param Swift_Mime_HeaderSet $headers
+ * @param Swift_Mime_ContentEncoder $encoder
+ * @param Swift_KeyCache $cache
+ * @param array $mimeTypes optional
+ */
+ public function __construct(Swift_Mime_HeaderSet $headers,
+ Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache,
+ $mimeTypes = array())
+ {
+ parent::__construct($headers, $encoder, $cache);
+ $this->setDisposition('attachment');
+ $this->setContentType('application/octet-stream');
+ $this->_mimeTypes = $mimeTypes;
+ }
+
+ /**
+ * Get the nesting level used for this attachment.
+ * Always returns {@link LEVEL_MIXED}.
+ * @return int
+ */
+ public function getNestingLevel()
+ {
+ return self::LEVEL_MIXED;
+ }
+
+ /**
+ * Get the Content-Disposition of this attachment.
+ * By default attachments have a disposition of "attachment".
+ * @return string
+ */
+ public function getDisposition()
+ {
+ return $this->_getHeaderFieldModel('Content-Disposition');
+ }
+
+ /**
+ * Set the Content-Disposition of this attachment.
+ * @param string $disposition
+ */
+ public function setDisposition($disposition)
+ {
+ if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition))
+ {
+ $this->getHeaders()->addParameterizedHeader(
+ 'Content-Disposition', $disposition
+ );
+ }
+ return $this;
+ }
+
+ /**
+ * Get the filename of this attachment when downloaded.
+ * @return string
+ */
+ public function getFilename()
+ {
+ return $this->_getHeaderParameter('Content-Disposition', 'filename');
+ }
+
+ /**
+ * Set the filename of this attachment.
+ * @param string $filename
+ */
+ public function setFilename($filename)
+ {
+ $this->_setHeaderParameter('Content-Disposition', 'filename', $filename);
+ $this->_setHeaderParameter('Content-Type', 'name', $filename);
+ return $this;
+ }
+
+ /**
+ * Get the file size of this attachment.
+ * @return int
+ */
+ public function getSize()
+ {
+ return $this->_getHeaderParameter('Content-Disposition', 'size');
+ }
+
+ /**
+ * Set the file size of this attachment.
+ * @param int $size
+ */
+ public function setSize($size)
+ {
+ $this->_setHeaderParameter('Content-Disposition', 'size', $size);
+ return $this;
+ }
+
+ /**
+ * Set the file that this attachment is for.
+ * @param Swift_FileStream $file
+ * @param string $contentType optional
+ */
+ public function setFile(Swift_FileStream $file, $contentType = null)
+ {
+ $this->setFilename(basename($file->getPath()));
+ $this->setBody($file, $contentType);
+ if (!isset($contentType))
+ {
+ $extension = strtolower(substr(
+ $file->getPath(), strrpos($file->getPath(), '.') + 1
+ ));
+
+ if (array_key_exists($extension, $this->_mimeTypes))
+ {
+ $this->setContentType($this->_mimeTypes[$extension]);
+ }
+ }
+ return $this;
+ }
+
+}