Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Download file from attachments #34

Open
Mishanki opened this issue Mar 5, 2022 · 1 comment
Open

Download file from attachments #34

Mishanki opened this issue Mar 5, 2022 · 1 comment

Comments

@Mishanki
Copy link

Mishanki commented Mar 5, 2022

How to parse and download file from attachments?

@Mishanki
Copy link
Author

Mishanki commented Mar 5, 2022

Test example for download first file from attachments

public function __invoke()
{
    $attachments = EmailLogModel::whereId(260)->value('attachments');

    $attachments = explode("\n\n", $attachments);
    foreach ($attachments as $i => $attachment) {
        $data = explode("\r\n\r\n", $attachment);
        $headersData = str_replace(";\r\n", ';', $data[0]);
        $headersData = explode("\r\n", $headersData);

        $headers = [];
        foreach ($headersData as $item) {
            $header = explode(':', $item);
            $headers[$header[0]] = $header[1];
        }

        $content = $data[1];

        return \Response::make(base64_decode($content, true), 200, $headers);
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant