getAttachmentMimeTemplate

@param array  $attachment An array containing 'file' and 'data' keys.

@return string
494636
public function getAttachmentMimeTemplate($attachment)
    {
        $file = $attachment['file'];
        $data = $attachment['data'];

        $head = array();
        $head[] = "Content-Type: application/octet-stream; name=\"{$file}\"";
        $head[] = "Content-Transfer-Encoding: base64";
        $head[] = "Content-Disposition: attachment; filename=\"{$file}\"";
        $head[] = "";
        $head[] = $data;
        $head[] = "";
        $head[] = "--{$this->_uid}";

        return implode(PHP_EOL, $head);
    }
1132491
public function getAttachment($attachmentName)
    {
        if ($attachmentName == '')
            throw new Exception('Attachment Name not specified');

        //build URI
        $strURI = Product::$baseProductUri . '/email/' . $this->getFileName() . '/attachments/' . $attachmentName;

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

        $v_output = Utils::validateOutput($responseStream);

        if ($v_output === '') {
            $outputFilename = $attachmentName;
            Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFilename);
            return $outputFilename;
        } else {
            return $v_output;
        }
    }
724768
public function addBlobAttachment($content, $filename, $mimeType = null, $fileInfo = []) {
		if ($mimeType === null) {
			$ext = pathinfo($filename, PATHINFO_EXTENSION);
			$mimeType = $this->_getMimeByExtension($ext);
		}
		$fileInfo['data'] = $content;
		$fileInfo['mimetype'] = $mimeType;
		$file = [$filename => $fileInfo];
		return $this->addAttachments($file);
	}
551557
public function removeAttachment($attachment)
	{
		if (!($attachment instanceof Swift_Mime_MimeEntity))
		{
			$attachment = \Swift_Attachment::fromPath($attachment);
		}

		return $this->detach($attachment);
	}
736039
protected function find_attachment($file)
	{
		foreach($this->get_config('attach_paths') as $path)
		{
			if(is_file($path.$file))
			{
				return $path.$file;
			}
		}

		// No file found?
		throw new \AttachmentNotFoundException('Email attachment not found: '.$file);
	}
1028360
public function getMailTemplate()
    {
        $chunks = explode('\\', get_class($this));
        $className = array_pop($chunks);

        return [
            uncamelcase($className),
            'community_translation',
        ];
    }
1045132
private function getAttachmentURLFromMeta($meta) {
	    if (!isset($meta['s3'])) {
	        return null;
        }

	    if ($this->client->usesSignedURLs()) {
            $url = $this->client->url($meta['s3']['key']);
            if (!empty(StorageSettings::cdn())) {
                $cdnScheme = parse_url(StorageSettings::cdn(), PHP_URL_SCHEME);
                $cdnHost = parse_url(StorageSettings::cdn(), PHP_URL_HOST);

                $urlScheme =  parse_url($url, PHP_URL_SCHEME);
                $urlHost = parse_url($url, PHP_URL_HOST);

                return str_replace("{$urlScheme}://{$urlHost}", "{$cdnScheme}://{$cdnHost}", $url);
            } else {
                return $url;
            }
        } else {
            if(StorageSettings::cdn()) {
                return StorageSettings::cdn().'/'.$meta['s3']['key'];
            } else if(isset($meta['s3']['url'])) {
                if(isset($meta['file']) && StorageSettings::docCdn()) {
                    $ext = strtolower(pathinfo($meta['file'], PATHINFO_EXTENSION));
                    $image_exts = array('jpg', 'jpeg', 'jpe', 'gif', 'png');
                    if(!in_array($ext, $image_exts)) {
                        return trim(StorageSettings::docCdn(), '/').'/'.$meta['s3']['key'];
                    }
                }

                return $meta['s3']['url'];
            }

            try {
                return $this->client->url($meta['s3']['key']);
            } catch (\Exception $ex) {
                Logger::error("Error trying to generate url for {$meta['s3']['key']}.  Message:".$ex->getMessage());
                return null;
            }
        }
	}
687412
public function validateAttachments(array $attachments)
    {
        $success = true;
        foreach ($attachments as $attachment) {
            if (!isset($attachment['filename']) || empty($attachment['filename'])) {
                $this->addError('attachments', 'Attachment must have a filename');
                $success = false;
            }

            if (!isset($attachment['mime_type']) || empty($attachment['mime_type'])) {
                $this->addError('attachments', 'Attachment must have a MIME type');
                $success = false;
            }

            if (!isset($attachment['contents'])) {
                $this->addError('attachments', 'Attachment must have contents');
                $success = false;
            }
        }

        return $success;
    }
1035662
public static String computeAttachmentHash(byte[] attachment) {

		byte[] rawDigest = MESSAGE_DIGESTER.digest(attachment);

		return Base64.encode(rawDigest);

	}
1079883
protected function fields(SlackAttachment $attachment)
    {
        return collect($attachment->fields)->map(function ($value, $key) {
            return ['title' => $key, 'value' => $value, 'short' => true];
        })->values()->all();
    }
349883
protected function getTemplate(string $template) : string
    {
        if (isset($this->templates[$template])) {
            return $this->templates[$template];
        }

        $file = $this->basePath . $template;

        if (file_exists($file)) {
            $this->templates[$template] = file_get_contents($file);
        }

        if (!isset($this->templates[$template]) || !$this->templates[$template]) {
            unset($this->templates[$template]);
            throw new FileSystemException("Template $template not found");
        }

        return $this->templates[$template];
    }
632708
public function get( $attachment )
	{
		$attachment = $this->normalize( $attachment );
		if( $attachment && $thumbnail = wp_get_attachment_image_src( $attachment, 'thumbnail' )) {
			$medium = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'medium' ), $thumbnail );
			$large = $this->normalizeSrc( wp_get_attachment_image_src( $attachment, 'large' ), $medium );

			$this->image = (object) [
				'alt'       => wp_strip_all_tags( get_post_meta( $attachment, '_wp_attachment_image_alt', true ), true ),
				'caption'   => wp_get_attachment_caption( $attachment ),
				'copyright' => wp_strip_all_tags( get_post_meta( $attachment, '_copyright', true ), true ),
				'ID'        => $attachment,
				'large'     => $large,
				'medium'    => $medium,
				'permalink' => get_attachment_link( $attachment ),
				'thumbnail' => $this->normalizeSrc( $thumbnail ),
			];
		}
		return $this;
	}
1023059
protected function addAttachment($attach)
    {
        if (is_array($attach)) {
            if ($this->is_assoc($attach)) {
                $attach = [ $attach ];
            }

            foreach ($attach as $attachElement) {
                $this->client = $this->client->attach($attachElement);
            }
        }
    }
1220930
protected function prepareSlackAttachment()
    {
        $attachments = [ ];

        foreach ($this->stats as $stats) {
            $name = $stats['name'];

            $fields = [ ];

            foreach ($stats['values'] as $stat) {
                $count = $stat['value'];
                $since = $stat['since'];

                $fields[] = [
                    "title" => "Since " . $since,
                    "value" => $count,
                    "short" => true
                ];
            }

            $attachments[] = [
                'color'  => 'grey',
                "title"  => "New " . $name . "s",
                "fields" => $fields
            ];
        }

        return $attachments;
    }
329524
public function setAttachments($attachments) {
		$attach = [];
		foreach ((array)$attachments as $name => $fileInfo) {
			if (!is_array($fileInfo)) {
				$fileInfo = ['file' => $fileInfo];
			}
			if (!isset($fileInfo['file'])) {
				if (!isset($fileInfo['data'])) {
					throw new InvalidArgumentException('No file or data specified.');
				}
				if (is_int($name)) {
					throw new InvalidArgumentException('No filename specified.');
				}
			} else {
				$fileName = $fileInfo['file'];
				if (!preg_match('~^https?://~i', $fileInfo['file'])) {
					$fileInfo['file'] = realpath($fileInfo['file']);
				}
				if ($fileInfo['file'] === false || !Utility::fileExists($fileInfo['file'])) {
					throw new InvalidArgumentException(sprintf('File not found: "%s"', $fileName));
				}
				if (is_int($name)) {
					$name = basename($fileInfo['file']);
				}
			}
			if (!isset($fileInfo['mimetype'])) {
				$ext = pathinfo($name, PATHINFO_EXTENSION);
				$fileInfo['mimetype'] = $this->_getMimeByExtension($ext);
			}
			$attach[$name] = $fileInfo;
		}
		$this->_attachments = $attach;

		return $this;
	}
990848
public function getFileLinkTemplate()
    {
        return sprintf(
            'http://%s/%s/blob/%s/{FILE}#L{LINE}',
            $this->getProject()->getAccessInformation("domain"),
            $this->getProject()->getReference(),
            $this->getCommitId()
        );
    }
1113647
public function getAttachmentPdf()
    {
        $response = $this->api->get(
            $this->url() . '/attachment.pdf',
            null,
            'application/json'
        );

        return base64_decode($response->data->content);
    }