{@inheritDoc} Returns a response containing an {@link Attachment}.
358878
public FbBotMillResponse build(MessageEnvelope envelope) {
		User recipient = getRecipient(envelope);
		Message message = new AttachmentMessage(attachment);
		message.setQuickReplies(quickReplies);
		return new FbBotMillMessageResponse(recipient, message);
	}
936116
public <V> V getAttachment(final AttachmentKey<V> key) {
        assert key != null;
        return key.cast(contextAttachments.get(key));
    }
843918
public function prepareAttachment($attachment)
    {
        if ($this->isFile($attachment) !== true) {
            return false;
        }
        //http://php.net/manual/en/class.finfo.php
        $fileInfo = new \finfo(FILEINFO_MIME_TYPE);
        $fileType = $fileInfo->file($attachment);
        $file = fopen($attachment, 'r');
        $fileContent = fread($file, filesize($attachment));
        $fileContent = chunk_split(base64_encode($fileContent));
        fclose($file);
        $msgContent = 'Content-Type: '.$fileType.'; name='.basename($attachment)."\r\n";
        $msgContent .= 'Content-Transfer-Encoding: base64'."\r\n";
        $msgContent .= 'Content-ID: <'.basename($attachment).'>'."\r\n";
        $msgContent .= "\r\n".$fileContent."\r\n\r\n";

        return $msgContent;
    }
1206153
public Attachment getAttachmentMetaData(String assetId, String attachmentId) throws IOException, BadVersionException, RequestFailureException {
        // At the moment can only get all attachments
        Asset ass = getAsset(assetId);
        List<Attachment> allAttachments = ass.getAttachments();
        for (Attachment attachment : allAttachments) {
            if (attachmentId.equals(attachment.get_id())) {
                return attachment;
            }
        }

        // Didn't find it so just return null
        return null;
    }
313175
function( bindingPoint, res ){
    var attachment = new Attachment( res );
    bindingPoint = 0|bindingPoint;

    this.detach( bindingPoint );

    this.attachments[bindingPoint.toString()] = attachment;
    this.attachmentsList.push( attachment );

    attachment._resize( this.width, this.height );
    attachment._attach( bindingPoint );
    return attachment;
  }
650700
@InterfaceAudience.Public
    public List<Attachment> getAttachments() {
        Map<String, Object> attachmentMetadata = getAttachmentMetadata();
        if (attachmentMetadata == null) {
            return new ArrayList<Attachment>();
        }
        List<Attachment> result = new ArrayList<Attachment>(attachmentMetadata.size());
        for (Map.Entry<String, Object> entry : attachmentMetadata.entrySet()) {
            Attachment attachment = toAttachment(entry.getKey(), entry.getValue());
            if (attachment != null) {
                result.add(attachment);
            }
        }
        return result;
    }
1314757
protected function getOrCreateAttachment(File $file, AttachableObjectInterface $object, $fieldName, FileKey $fileKey)
    {
        $attachment = $this->getAttachment($fileKey->getKey());
        
        if (null === $attachment)
        {
            $schema = $this->getSchemaForObject($object, $fieldName);
            
            $attachment = new Attachment();
            $attachment
                ->setFileKey($fileKey->getKey())
                ->setFileSize($file->getSize())
                ->setFileType($file->getMimeType())
                ->setStorageName($schema->getStorage()->getName())
                ->setStorageDepth($schema->getStorageDepth())
                ->setHashType($schema->getHashCallableAsString())
            ;
        }
        
        return $attachment;
    }
19208
public static function getAttachment($attachmentID,$options = [])
    {
        $result     = null;
        $downloader = new Priloha($attachmentID,$options);
        if ($downloader->lastResponseCode == 200) {

            $downloader->doCurlRequest(self::getDownloadURL($downloader), 'GET');
            if ($downloader->lastResponseCode == 200) {
                $result = $downloader->lastCurlResponse;
            }
        }
        return $result;
    }
278943
public E attachment(byte[] attachment, String name) {
        attachments.put(name, attachment);
        return getThis();
    }
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;
        }
    }
93265
public function getAttachment($attachmentIndex)
    {

        $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/attachments/' . $attachmentIndex;
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
        $json = json_decode($responseStream);
        return $json->Attachment;
    }
51276
public static function create(string $attachmentPublicUuid, array $customHeaders = []): BunqResponseString
    {
        $apiClient = new ApiClient(static::getApiContext());
        $responseRaw = $apiClient->post(
            vsprintf(
                self::ENDPOINT_URL_CREATE,
                []
            ),
            [self::FIELD_ATTACHMENT_PUBLIC_UUID => $attachmentPublicUuid],
            $customHeaders
        );

        return BunqResponseString::castFromBunqResponse(
            static::processForUuid($responseRaw)
        );
    }
753992
public static SoapAttachment from(Attachment attachment) {
        SoapAttachment soapAttachment = new SoapAttachment();

        String contentId = attachment.getContentId();
        if (contentId.startsWith("<") && contentId.endsWith(">")) {
            contentId = contentId.substring(1, contentId.length() - 1);
        }
        soapAttachment.setContentId(contentId);
        soapAttachment.setContentType(attachment.getContentType());

        if (attachment.getContentType().startsWith("text")) {
            try {
                soapAttachment.setContent(FileUtils.readToString(attachment.getInputStream()).trim());
            } catch (IOException e) {
                throw new CitrusRuntimeException("Failed to read SOAP attachment content", e);
            }
        } else {
            // Binary content
            soapAttachment.setDataHandler(attachment.getDataHandler());
        }

        soapAttachment.setCharsetName(Citrus.CITRUS_FILE_ENCODING);

        return soapAttachment;
    }
1138180
public function getAttachment()
    {
        if ($this->relatedObject === null && $this->isRelatedObjectResolved === false) {
            $this->isRelatedObjectResolved = true;

            try {
                $model = $this->modelFactory()->create(Attachment::class)->load($this->attachmentId());
                if ($model->id()) {
                    $this->relatedObject = $model;

                    $type = $model->type();
                    if ($type !== $model->objType()) {
                        $this->relatedObject = $this->modelFactory()->create($type)->setData($model->data());
                    }
                }
            } catch (Exception $e) {
                throw new LogicException(sprintf(
                    'Could not load the related object of the relationship: %s',
                    $e->getMessage()
                ), 0, $e);
            }
        }

        return $this->relatedObject;
    }
1144033
public function sendFile($filePath, $fileName = null)
    {
        if ($filePath instanceof File) {
            $filePath = $filePath->getPathname();
        }

        $response = new Response();
        $response->headers->set('Cache-Control', 'private');
        $response->headers->set('Content-Type', mime_content_type($filePath));
        $response->headers->set('Content-Disposition', 'attachment;filename="' . ($fileName ?: basename($filePath)). '"');
        $response->headers->set('Content-Length', filesize($filePath));

        $response->setContent(file_get_contents($filePath));

        return $response;
    }
745139
public function downloadAction()
    {
        $fileManager = $this->container->get('thrace_media.filemanager');
        $filepath = $this->getRequest()->get('filepath');
        $filename = SlugFilter::filter($this->getRequest()->get('filename'));

        $content = $fileManager->getPermanentFileBlobByName($filepath);

        $response = new Response($content);
        $response->headers->set('Content-Length', mb_strlen($content));
        $response->headers->set('Content-Type', $this->getMimeType($content));
        $response->headers->set('Content-Disposition', 'attachment;filename=' . $filename);
        $response->expire();
        
        return $response;
    }
1176903
@Override
    public void handle(RequestDTO requestDTO, Attachment attachment) {
        if (handler != null) {
            handler.handle(requestDTO, attachment);
        }
        if (attachment != null && attachment.getAppIdToken() != null
                && StringUtil.isNotEmpty(attachment.getAppIdToken().getAppId())
                && StringUtil.isNotEmpty(attachment.getAppIdToken().getToken())) {
            requestDTO.setAppId(attachment.getAppIdToken().getAppId());
            requestDTO.setToken(attachment.getAppIdToken().getToken());
        }
    }