码迷,mamicode.com
首页 > Windows程序 > 详细

netcore webapi 输出imges,在docker里面swagger报错

时间:2020-07-15 15:54:48      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:install   报错   webapi   cat   info   qrcode   format   pixel   turn   

技术图片

 

 

发现: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

技术图片

 

netcore webapi 输出imges,在docker里面swagger报错

标签:install   报错   webapi   cat   info   qrcode   format   pixel   turn   

原文地址:https://www.cnblogs.com/25miao/p/13305011.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!