microsoftgraph / microsoftgraph/msgraph-sdk-php

v2 plain text attachment arrives unreadable

Aperta
#1,458 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@SilasKenneth ci sta già lavorando.

Dal 21/2/2024.

area: outlook bug
Lingua principale
PHP
Stelle
669
Fork
150
Merge medio
15h 21m
PR unite (30g)
3

Descrizione

Hello,

We're migrating code that was using v1 of the SDK to v2, however I'm running into an issue receiving attachments.
The test code attaches a plain text file to the message but upon receiving the email, the file is unreadable.

The exact same file works fine with v1 of the SDK.

Sample code:


$attach = [];
foreach ($attachments as $path => $mimeType) {
    if (!is_readable($path))
        throw new \InvalidArgumentException("$path is not readable and cannot be attached.");

    $attachment = new FileAttachment();
    $attachment->setOdataType('#microsoft.graph.fileAttachment');
    $attachment->setName(pathinfo($path, PATHINFO_BASENAME));
    $attachment->setContentType($mimeType);
    /* DEBUG */
    print($attachment->getContentType() . "\n");    // "text/plain"
    $resource = Utils::tryFopen($path, 'r');
    $attachment->setContentBytes(Utils::streamFor($resource));
    echo $attachment->getContentBytes()->getContents();     // "sample used for attachments" -- as expected
    $attachment->getContentBytes()->rewind();   // for debugging
    $attach[] = $attachment;
}
$message->setAttachments($attach);

File that gets attached: sample_attachment.txt

Received file: test_attachment_received.txt

Everything else in the received email is as expected.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.