I have u开发者_JAVA百科sed the following line
image=URL(r=request,f='nonhomog_plot') to make the image in web2py. The filename of the image will be "nonhomog_plot.png". How can I control the filename of the image? I want the filename to contain an user input variable + "_Figure1.png".Please ask these questions on the web2py mailing list. That is were the experts are. Here you tend to get generic answers by people who may not be web2py experts. Anyway.
image=URL(r=request,f='nonhomog_plot')
can be rewritten as
image=URL('nonhomog_plot.png')
where I assume nonhomog_plot is a web2py action that streams the file. something like
def nonhomog_plot():
return response.stream(open('filename.png','rb'))
Now you can add
def nonhomog_plot():
filename='Figure1.png'
response.headers['Content-Disposition']='attachment; filename='+filename
return response.stream(open('filename.png','rb'))
精彩评论