V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
ibegyourpardon
V2EX  ›  问与答

image object 能直接转 file object 么

  •  
  •   ibegyourpardon · Aug 3, 2020 · 2026 views
    This topic created in 2104 days ago, the information mentioned may be changed or developed.

    微信公众号开发,那头需要收文件对象传过去。

    这头 pillow 画了半天画的是 image object……

    试来试去一下子都没搞定。

    暂时用另存个文件然后再打开文件,上传文件流的方式解决了,就是感觉好蠢。为啥不能内存里直接转成个 file object……

    2 replies    2020-08-03 19:33:37 +08:00
    scsb
        1
    scsb  
       Aug 3, 2020 via iPhone
    try ?
    zxlzy
        2
    zxlzy  
       Aug 3, 2020   ❤️ 1
    google 搜了一下。。把生成的 byte array write 到 response 里就可以了
    convert-pil-image-to-byte-array
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   951 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 21:20 · PVG 05:20 · LAX 14:20 · JFK 17:20
    ♥ Do have faith in what you're doing.