Skip to content
Discussion options

You must be logged in to vote

Cam up with the following that's working:

    $stream = $media->stream();
    $file = stream_get_contents($stream);
    fclose($stream);

    $ext = MimeTypes::getDefault()->getExtensions($media->mime_type)[0] ?? null; // TODO: throw if extension not knowable
    $base64 = 'data:application/' . $ext . ';base64,' . base64_encode($file);
    unset($file);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SlyDave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant