代码之家  ›  专栏  ›  技术社区  ›  brnd0 Diego Ponciano

swift_attachment-如何获取附件文件的路径

  •  0
  • brnd0 Diego Ponciano  · 技术社区  · 8 年前

    使用 Swift_Attachment API 我可以得到文件名 getFilename() 但我找不到获取文件完整路径的方法。

    我用的是拉维5.5和 this email_log library 但需要修改它,这样文件就不会存储在数据库中。

    我使用 Swift_Message->getChildren() 里面有

    -body: Swift_ByteStream_FileByteStream { 
      ...
      -path: "/root/path/to/my/file"
      ...
    }
    

    如果我能得到 -body 作为一个 Swift_ByteStream_FileByteStream 实例,然后我可以使用 getPath() 从 here 但我不知道怎么做。

    1 回复  |  直到 8 年前
        1
  •  0
  •   brnd0 Diego Ponciano    8 年前

    决定从附件而不是从路径存储文件,因为我找不到提取路径的方法。

        $messageId = strtok($message->getId(), '@');
        foreach ($message->getChildren() as $child) {
            $attachmentPath = 'email_log_attachments/' . $messageId . '/' . $child->getFilename();
            Storage::put($attachmentPath,$child->getBody());
        }