我知道Docker有一个嵌入式Dns解析器.
当我在自己的桥上运行一个容器时:
$ docker run -it --rm --privileged --network=mybridge xxx bash
root@18243bfe6b50:/# cat /etc/resolv.conf
nameserver 127.0.0.11
options ndots:0
root@18243bfe6b50:/# netstat -anop
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name Timer
tcp 0 0 127.0.0.11:45997 0.0.0.0:* LISTEN - off (0.00/0/0)
udp 0 0 127.0.0.11:49614 0.0.0.0:*
it shows there is a dns resolver, and iptables help do a port transfer.
root@18243bfe6b50:/# iptables -nvL -t nat
.....
Chain DOCKER_OUTPUT (1 references)
pkts bytes target prot …Run Code Online (Sandbox Code Playgroud) 我有一个ReportPdf继承自Prawn::Document.
当我从Rails控制台测试时,pdf中嵌入的png图像正确呈现.
ReportPdf.new(param1,param2).render_file('/Users/ZZ/Desktop/test.pdf')
Run Code Online (Sandbox Code Playgroud)
但是,当控制器请求时:
def generate_pdf
pdf = ReportPdf.new(param1, param2)
send_data pdf.render, filename: 'report.pdf', type: 'application/pdf'
end
Run Code Online (Sandbox Code Playgroud)
图像未呈现,其他内容呈现没有任何问题.
我尝试过使用Amazon S3的本地图像和图像.两者在控制台中都可以正常工作,但不能从控
generate_pdf控制器中的方法也给出了正确的pdf.如果我直接请求PDF,则会正确呈现PDF.我用Postman测试了它.
但是,仅当从Angular中的导出按钮请求时,才会呈现PDF中的图像.以下是实现:
后端:
class ReportPdf < Prawn::Document
def initialize(param1, param2)
super()
@param1 = param1
@date = Time.zone.parse(param2) || Time.zone.now
header
end
def header
img = open('https://s3-ap-southeast2.amazonaws.com/bucket/folder/logo.png')
# use local image
# img = "#{Rails.root}/app/assets/images/logo.png"
data = [[{ image: img, image_width: 150, vposition: :center },
"#{@param1.name} - #{@param2.suburb}"]]
table(data, cell_style: { borders: {},
valign: :center, …Run Code Online (Sandbox Code Playgroud)