zoukankan      html  css  js  c++  java
  • netcore webapi 输出imges,在docker里面swagger报错

    发现:service中有个webapi输出了:

    public Bitmap GetLogoQRCode(string url, string logoPath, int pixel)
            {
                return QRCoderHelper.GetLogoQRCode(url, logoPath, pixel);
            }

    在IIS里面正常,但是在docker里面就报错。

    IIS里面swagger中显示该方法返回的是:

    "System.Drawing.Bitmap"

    -------------
    暂时改为:

    public FileResult GetPTQRCode(QRCoderDto dto)
            {
                try
                {
                    var bitmap = QRCoderHelper.GetPTQRCode(dto.Url, dto.Pixel);
                    MemoryStream ms = new MemoryStream();
                    bitmap.Save(ms, ImageFormat.Jpeg);
    
                    return new FileContentResult(ms.ToArray(), "image/png");
                }
                catch (Exception)
                {
                    throw new UserFriendlyException("二维码生成异常,请检查");
                }
            }

    然后在dockerfile中加入:

    RUN  mv /etc/apt/sources.list /etc/apt/sources.list.bak
    RUN  echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >> /etc/apt/sources.list
    RUN  echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list
    RUN  echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list
    RUN  echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list
    RUN apt-get update -y
    RUN apt-get install libgdiplus

  • 相关阅读:
    PO-审批设置
    DIS-接收方式设置入口
    网约车
    汽车租赁
    共享单车
    共享充电宝
    佛教四大名山|道教四大名山|五岳|名山
    我读过的诗词文章书籍
    我看过的电影
    redis异常解决:jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set
  • 原文地址:https://www.cnblogs.com/25miao/p/13305011.html
Copyright © 2011-2022 走看看