Hello everybody, I expect strange behaviour when delivering image data out of the database to the browser. class AssetController def view_article_image image = ArticleImage.find params[:id] send_data image.data, :type => "image/jpeg" end end the above action loads an image from database and sends it to the client. it works fine, but the browser pops up the prompt ''open or save file to disk?'' (ie 6 + opera) *arrghh* I expected the browser to just render the image as it''s content type is of known type "image/jpeg". it should behave identical to a static jpeg residing somewhere in the /public folder. Please, what''s the difference between static jpegs streamed directly from the server and dynamic jpegs served from a controller action? are there some headers specific required? I cluelessly played around with ''Content-Disposition'' and various caching directives but for some reason the prompt still pops up... Any help greatly appreciated!! :-) Peter
Note: I found out that Webrick adds the custom header Content-Disposition: attachment the the output which explains everything. does somebody know how to suppress that behaviour? On Mon, 07 Nov 2005 12:21:42 +0100, Pete <pertl-BA+cFGlbTmA@public.gmane.org> wrote:> Hello everybody, > > I expect strange behaviour when delivering image data out of > the database to the browser. > > class AssetController > def view_article_image > image = ArticleImage.find params[:id] > send_data image.data, :type => "image/jpeg" > end > end > > the above action loads an image from database and sends it to the client. > it works fine, but the browser pops up the prompt ''open or save file to > disk?'' (ie 6 + opera) > > *arrghh* > > I expected the browser to just render the image as it''s content type is > of > known type "image/jpeg". it should behave identical to a static jpeg > residing > somewhere in the /public folder. > > Please, what''s the difference between static jpegs streamed directly > from the server > and dynamic jpegs served from a controller action? are there some > headers specific required? > > I cluelessly played around with ''Content-Disposition'' and various > caching directives but > for some reason the prompt still pops up... > > Any help greatly appreciated!! :-) > > Peter > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
> I found out that Webrick adds the custom header> Content-Disposition: attachment> the the output which explains everything. > does somebody know how to suppress that behaviour?Add the option :disposition => 'inline' to the call to send_data Tom _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks you very much!!!!! I really thought it comes from WEBrick... Best regards Peter On Mon, 07 Nov 2005 12:43:29 +0100, Tom Ward <tom-FF2hOUnQ1ZmsTnJN9+BGXg@public.gmane.org> wrote:>> I found out that Webrick adds the custom header > >> Content-Disposition: attachment > >> the the output which explains everything. >> does somebody know how to suppress that behaviour? > > Add the option :disposition => ''inline'' to the call to send_data > > Tom
Pete,您好! suppose test.rb will output image, then <image src="test.rb".....> should not popup window ? regards! ======== 2005-11-07 12:21:00 您在来信中写道: ======= Hello everybody, I expect strange behaviour when delivering image data out of the database to the browser. class AssetController def view_article_image image = ArticleImage.find params[:id] send_data image.data, :type => "image/jpeg" end end the above action loads an image from database and sends it to the client. it works fine, but the browser pops up the prompt ''open or save file to disk?'' (ie 6 + opera) *arrghh* I expected the browser to just render the image as it''s content type is of known type "image/jpeg". it should behave identical to a static jpeg residing somewhere in the /public folder. Please, what''s the difference between static jpegs streamed directly from the server and dynamic jpegs served from a controller action? are there some headers specific required? I cluelessly played around with ''Content-Disposition'' and various caching directives but for some reason the prompt still pops up... Any help greatly appreciated!! :-) Peter _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails = = = = = = = = = = = = = = = = = = = = = = 致 礼! z-axis z_axis-9Onoh4P/yGk@public.gmane.org 2005-11-07 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
beg your pardon?! the approach I now use is "database images using http caching" more here: http://manuals.rubyonrails.com/read/chapter/62 It''s just perfect for me !! :-) On Mon, 07 Nov 2005 14:33:24 +0100, z-axis <z_axis-9Onoh4P/yGk@public.gmane.org> wrote:> Pete,您好! > > suppose test.rb will output image, then <image > src="test.rb".....> should not popup window ? > > regards! > > ======== 2005-11-07 12:21:00 您在来信中写道: =======> > Hello everybody, > > I expect strange behaviour when delivering image data out of > the database to the browser. > > class AssetController > def view_article_image > image = ArticleImage.find params[:id] > send_data image.data, :type => "image/jpeg" > end > end > > the above action loads an image from database and sends it to the client. > it works fine, but the browser pops up the prompt ''open or save file to > disk?'' (ie 6 + opera) > > *arrghh* > > I expected the browser to just render the image as it''s content type is > of > known type "image/jpeg". it should behave identical to a static jpeg > residing > somewhere in the /public folder. > > Please, what''s the difference between static jpegs streamed directly from > the server > and dynamic jpegs served from a controller action? are there some headers > specific required? > > I cluelessly played around with ''Content-Disposition'' and various caching > directives but > for some reason the prompt still pops up... > > Any help greatly appreciated!! :-) > > Peter > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > = = = = = = = = = = = = = = = = = = = = = > 致 > 礼! > > z-axis > z_axis-9Onoh4P/yGk@public.gmane.org > 2005-11-07