Ok i''ve gotten the file upload working (I have users uploading images basically to be viewed on another page) but not sure how to display it on a facebook canvas. Do I need to present it in a iframe? PhotosController: def code_image @image_data = Photo.find(params[:id]) @image = @image_data.binary_data send_data(@image, :type => @image_data.content_type, :filename => @image_data.filename, :disposition => ''inline'') end show.fbml.erb: <% for column in Photo.content_columns %> <%= column.human_name %> <% if column.name == "binary_data" %> <%= image_tag("/photos/code_image/#{@photo.id}", :alt => "Image") %> <% else %> <%=h @photo.send(column.name) %> <% end %> <% end %> the URL i''m directly going to to view the image: http://apps.new.facebook.com/myapp/photos/code_image/1 If I view the source html it shows a bunch of binary code of the image in the fbml source
Is that path relative to RAILS_ROOT/public/images? Appears your trying to use a controller path to access the images. I think image_tag inherently uses RAILS_ROOT/public/images prepended to to the string, unless a fully qualified URL is provided, which seems your trying to use a relative path. On Mon, Aug 25, 2008 at 10:53 PM, Allen Walker <auswalk at gmail.com> wrote:> Ok i''ve gotten the file upload working (I have users uploading images > basically to be viewed on another page) but not sure how to display it on a > facebook canvas. Do I need to present it in a iframe? > > PhotosController: > > def code_image > @image_data = Photo.find(params[:id]) > @image = @image_data.binary_data > send_data(@image, :type => @image_data.content_type, :filename => > @image_data.filename, :disposition => ''inline'') > end > > show.fbml.erb: > > <% for column in Photo.content_columns %> > <%= column.human_name %> > <% if column.name == "binary_data" %> > <%= image_tag("/photos/code_image/#{@photo.id}", :alt => > "Image") %> > <% else %> > <%=h @photo.send(column.name) %> > <% end %> > <% end %> > > the URL i''m directly going to to view the image: > > http://apps.new.facebook.com/myapp/photos/code_image/1 > > > If I view the source html it shows a bunch of binary code of the image in > the fbml source > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20080825/8311612f/attachment.html>
Actually I got most of the code from here: http://railsforum.com/viewtopic.php?id=4642 They explicitly use the image_tag which is ultimately calling a method in the controller. In the fbml source when I hit the url it just fires up bunch of binary in the page . So it''s finding the image blob but not rendering it correctly. Ken Schroeder wrote:> Is that path relative to RAILS_ROOT/public/images? Appears your trying > to use a controller path to access the images. I think image_tag > inherently uses RAILS_ROOT/public/images prepended to to the string, > unless a fully qualified URL is provided, which seems your trying to > use a relative path. > > On Mon, Aug 25, 2008 at 10:53 PM, Allen Walker <auswalk at gmail.com > <mailto:auswalk at gmail.com>> wrote: > > Ok i''ve gotten the file upload working (I have users uploading > images basically to be viewed on another page) but not sure how to > display it on a facebook canvas. Do I need to present it in a iframe? > > PhotosController: > > def code_image > @image_data = Photo.find(params[:id]) > @image = @image_data.binary_data > send_data(@image, :type => @image_data.content_type, :filename > => @image_data.filename, :disposition => ''inline'') > end > > show.fbml.erb: > > <% for column in Photo.content_columns %> > <%= column.human_name %> > <% if column.name <http://column.name> == "binary_data" %> > <%= image_tag("/photos/code_image/#{@photo.id > <http://photo.id>}", :alt => "Image") %> > <% else %> > <%=h @photo.send(column.name <http://column.name>) %> > <% end %> > <% end %> > > the URL i''m directly going to to view the image: > > http://apps.new.facebook.com/myapp/photos/code_image/1 > > > If I view the source html it shows a bunch of binary code of the > image in the fbml source > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org <mailto:Facebooker-talk at rubyforge.org> > http://rubyforge.org/mailman/listinfo/facebooker-talk > >
I see your point now.. This is tricky. If I go to my host URL it auto redirects back to facebook. Looks like I''m gonna have to set a route up or something.. Ken Schroeder wrote:> Is that path relative to RAILS_ROOT/public/images? Appears your trying > to use a controller path to access the images. I think image_tag > inherently uses RAILS_ROOT/public/images prepended to to the string, > unless a fully qualified URL is provided, which seems your trying to > use a relative path. > > On Mon, Aug 25, 2008 at 10:53 PM, Allen Walker <auswalk at gmail.com > <mailto:auswalk at gmail.com>> wrote: > > Ok i''ve gotten the file upload working (I have users uploading > images basically to be viewed on another page) but not sure how to > display it on a facebook canvas. Do I need to present it in a iframe? > > PhotosController: > > def code_image > @image_data = Photo.find(params[:id]) > @image = @image_data.binary_data > send_data(@image, :type => @image_data.content_type, :filename > => @image_data.filename, :disposition => ''inline'') > end > > show.fbml.erb: > > <% for column in Photo.content_columns %> > <%= column.human_name %> > <% if column.name <http://column.name> == "binary_data" %> > <%= image_tag("/photos/code_image/#{@photo.id > <http://photo.id>}", :alt => "Image") %> > <% else %> > <%=h @photo.send(column.name <http://column.name>) %> > <% end %> > <% end %> > > the URL i''m directly going to to view the image: > > http://apps.new.facebook.com/myapp/photos/code_image/1 > > > If I view the source html it shows a bunch of binary code of the > image in the fbml source > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org <mailto:Facebooker-talk at rubyforge.org> > http://rubyforge.org/mailman/listinfo/facebooker-talk > >
So i guess my question then is, how do I setup a route so that if I do "www.myhost.com/photo/show/1" it will not go thru facebook but instead go directly to my host. Allen Walker wrote:> I see your point now.. > > This is tricky. If I go to my host URL it auto redirects back to > facebook. Looks like I''m gonna have to set a route up or something.. >
Well my prob is I can''t even do "www.myhost.com/photo/show/1 <http://www.myhost.com/photo/show/1>". If I do that it redirects to my apps.facebook.com/myapp I''m not sure how to bypass that. Ken Schroeder wrote:> Yeah I had this same question more or less week or so ago I ended up > hard coding my callback_url and path in the view. :( > > On Tue, Aug 26, 2008 at 1:23 AM, Allen Walker <auswalk at gmail.com > <mailto:auswalk at gmail.com>> wrote: > > So i guess my question then is, how do I setup a route so that if > I do "www.myhost.com/photo/show/1 > <http://www.myhost.com/photo/show/1>" it will not go thru facebook > but instead go directly to my host. > > > Allen Walker wrote: > > I see your point now.. > > This is tricky. If I go to my host URL it auto redirects back > to facebook. Looks like I''m gonna have to set a route up or > something.. > > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org <mailto:Facebooker-talk at rubyforge.org> > http://rubyforge.org/mailman/listinfo/facebooker-talk > >
David Clements
2008-Aug-26 05:31 UTC
[Facebooker-talk] rendering images from a file upload
I think you need to skip the authentication filter for that controller. skip_before_filter :ensure_authenticated_to_facebook Then it won''t redirect back to facebook. Dave On Mon, Aug 25, 2008 at 11:29 PM, Allen Walker <auswalk at gmail.com> wrote:> Well my prob is I can''t even do "www.myhost.com/photo/show/1 < > http://www.myhost.com/photo/show/1>". If I do that it redirects to my > apps.facebook.com/myapp > > I''m not sure how to bypass that. > > Ken Schroeder wrote: > >> Yeah I had this same question more or less week or so ago I ended up hard >> coding my callback_url and path in the view. :( >> >> On Tue, Aug 26, 2008 at 1:23 AM, Allen Walker <auswalk at gmail.com <mailto: >> auswalk at gmail.com>> wrote: >> >> So i guess my question then is, how do I setup a route so that if >> I do "www.myhost.com/photo/show/1 >> <http://www.myhost.com/photo/show/1>" it will not go thru facebook >> but instead go directly to my host. >> >> >> Allen Walker wrote: >> >> I see your point now.. >> >> This is tricky. If I go to my host URL it auto redirects back >> to facebook. Looks like I''m gonna have to set a route up or >> something.. >> >> >> _______________________________________________ >> Facebooker-talk mailing list >> Facebooker-talk at rubyforge.org <mailto:Facebooker-talk at rubyforge.org> >> http://rubyforge.org/mailman/listinfo/facebooker-talk >> >> >> > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20080825/ed143fcd/attachment-0001.html>
Thanks alot, that worked! David Clements wrote:> I think you need to skip the authentication filter for that controller. > > skip_before_filter :ensure_authenticated_to_facebook > > Then it won''t redirect back to facebook. > > Dave > > > On Mon, Aug 25, 2008 at 11:29 PM, Allen Walker <auswalk at gmail.com > <mailto:auswalk at gmail.com>> wrote: > > Well my prob is I can''t even do "www.myhost.com/photo/show/1 > <http://www.myhost.com/photo/show/1> > <http://www.myhost.com/photo/show/1>". If I do that it redirects > to my apps.facebook.com/myapp <http://apps.facebook.com/myapp> > > I''m not sure how to bypass that. > > Ken Schroeder wrote: > > Yeah I had this same question more or less week or so ago I > ended up hard coding my callback_url and path in the view. :( > > > On Tue, Aug 26, 2008 at 1:23 AM, Allen Walker > <auswalk at gmail.com <mailto:auswalk at gmail.com> > <mailto:auswalk at gmail.com <mailto:auswalk at gmail.com>>> wrote: > > So i guess my question then is, how do I setup a route so > that if > I do "www.myhost.com/photo/show/1 > <http://www.myhost.com/photo/show/1> > <http://www.myhost.com/photo/show/1>" it will not go thru > facebook > > but instead go directly to my host. > > > Allen Walker wrote: > > I see your point now.. > > This is tricky. If I go to my host URL it auto > redirects back > to facebook. Looks like I''m gonna have to set a route up or > something.. > > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > <mailto:Facebooker-talk at rubyforge.org> > <mailto:Facebooker-talk at rubyforge.org > <mailto:Facebooker-talk at rubyforge.org>> > > http://rubyforge.org/mailman/listinfo/facebooker-talk > > > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org <mailto:Facebooker-talk at rubyforge.org> > http://rubyforge.org/mailman/listinfo/facebooker-talk > >
After you accept the upload, how to you redirect back into the facebook canvas? My create method in my controller doesn''t redirect back into apps.facebook.com/myapp/photos but rather www.myhost.com/photos: def create @photo = Photo.new(params[:photo]) if @photo.save flash[:notice] = "Photo Saved" redirect_to photos_url else render :action => "new" end end Ken Schroeder wrote:> Yeah I had this same question more or less week or so ago I ended up > hard coding my callback_url and path in the view. :( > > On Tue, Aug 26, 2008 at 1:23 AM, Allen Walker <auswalk at gmail.com > <mailto:auswalk at gmail.com>> wrote: > > So i guess my question then is, how do I setup a route so that if > I do "www.myhost.com/photo/show/1 > <http://www.myhost.com/photo/show/1>" it will not go thru facebook > but instead go directly to my host. > > > Allen Walker wrote: > > I see your point now.. > > This is tricky. If I go to my host URL it auto redirects back > to facebook. Looks like I''m gonna have to set a route up or > something.. > > > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org <mailto:Facebooker-talk at rubyforge.org> > http://rubyforge.org/mailman/listinfo/facebooker-talk > >
Thank you sir. Duh ;-) BJ Clark wrote:> :canvas => true > > > On Aug 26, 2008, at 9:02 PM, Allen Walker wrote: > >> After you accept the upload, how to you redirect back into the >> facebook canvas? My create method in my controller doesn''t redirect >> back into apps.facebook.com/myapp/photos but rather >> www.myhost.com/photos: >> >> def create >> @photo = Photo.new(params[:photo]) >> if @photo.save >> flash[:notice] = "Photo Saved" >> redirect_to photos_url >> else >> render :action => "new" >> end >> end >> >> Ken Schroeder wrote: >>> Yeah I had this same question more or less week or so ago I ended up >>> hard coding my callback_url and path in the view. :( >>> >>> On Tue, Aug 26, 2008 at 1:23 AM, Allen Walker <auswalk at gmail.com >>> <mailto:auswalk at gmail.com>> wrote: >>> >>> So i guess my question then is, how do I setup a route so that if >>> I do "www.myhost.com/photo/show/1 >>> <http://www.myhost.com/photo/show/1>" it will not go thru facebook >>> but instead go directly to my host. >>> >>> >>> Allen Walker wrote: >>> >>> I see your point now.. >>> >>> This is tricky. If I go to my host URL it auto redirects back >>> to facebook. Looks like I''m gonna have to set a route up or >>> something.. >>> >>> >>> _______________________________________________ >>> Facebooker-talk mailing list >>> Facebooker-talk at rubyforge.org <mailto:Facebooker-talk at rubyforge.org> >>> http://rubyforge.org/mailman/listinfo/facebooker-talk >>> >>> >> >> _______________________________________________ >> Facebooker-talk mailing list >> Facebooker-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/facebooker-talk > >