Any ptrs on how (or ptrs to postings describing how) to do this?
Or is there some Facebooker support for this that I havent spotted
yet?
Thx,
Steve
Mike
> --
> You received this message because you are subscribed to the Google Groups "facebooker" group.
> To post to this group, send email to faceb...@googlegroups.com.
> To unsubscribe from this group, send email to facebooker+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/facebooker?hl=en.
>
--
Mike Mangino
http://www.elevatedrails.com
I understand that you're saying that I dont even need to do the
iframe, but with the iframe, I guess I'm having the file stripped out
because it's only using the iframe to get the template containing the
file_field_tag's form for display, but it posts back via FB...? I
guess this is true because I'm getting fb_sig_params back on the
receiving action. Is that right?
Now, I'm trying to do all of this in the context of a
facebook_form_for where I'm creating/editing an model that has an
associated image. So, in the context of the form_for, I now tried:
<%= f.file_field :banner, :label => "Select File" %>
but I find that when my controller's action is hit, I only get the
filename, none of the data.
So, is it still getting stripped (regardless of the use of an iframe)
and there's no way to have this in the context of this form?
In other words, I guess that's why I cant just do the
<%= f.file_field :banner, :label => "Select File" %>
within\ that form.
I'll need a subform with its own submit button posting back directly
to my server?
On Feb 4, 2:50 pm, Joseph Sofaer <joseph.sof...@gmail.com> wrote:
> I think what Mike is trying to point out is that if you direct the
> request to your canvas url (ie apps.facebook.com/myapp) the data will
> not get passed on. You have to set your form to point straight to your
> app (like: <form action="<%= ActionController::Base.asset_host +
> "/photos" %> method="post" enctype="multipart/form-data">").
> Best,
> Joseph
>
Any other ideas?
Joseph - It sounds like you've gotten something liek this to work...
If so, any code you can post showing what you did?
On Feb 4, 3:17 pm, Joseph Sofaer <joseph.sof...@gmail.com> wrote:
> I haven't use facebook_form_for but you might be able to overwrite the
> action. The other thing I had to do here was redirect explicitly back
> tohttp://apps.facebook.com/canvas_nameon that request.
> J.
The idea is that I have a Forum model object that needs to have a
banner image file uploaded.
Given that I have an upload form within the form for editing the
Forum, I had to do it as an iframe.
So, within the template for model object's editing form I have:
<%= f.text '<fb:iframe width="420" height="100" frameborder="0"
src="' + url_for(:controller => :forums, :action
=> :upload_banner, :id => @forum.id, :only_path => false, :canvas =>
false) + '"></fb:iframe>' %>
note that I set the src for the iframe with url_for() and
set :only_path => false and :canvas => false. This gives me a full url
that pts back to an action in my controller on my server, thus
bypassing FB for what happens in the iframe.
The 'upload_banner' is both an action in my controller and a template
for the upload form.
upload_banner.erb is that template and looks like this:
<% form_tag(url_for(:controller => :forums, :action
=> :upload_banner_post, :id => @forum.id, :only_path => false, :canvas
=> false), :multipart => true) do %>
<div style="font-family:lucida grande,tahoma,verdana,arial,sans-
serif; font-size:11px;">
<label style="font-family:lucida grande,tahoma,verdana,arial,sans-
serif; font-size:11px;" for="upload_file">Select File</label>: <%=
file_field_tag :file %> <%= submit_tag "Upload" %>
</div>
<% end %>
Note again the url_for() which ensures that the POST'ing action from
the form goes directly back to my server instead of thru FB so that
the file contents get submitted to me. (If you're wondering about that
styling, I grabbed that from the FB css so that what's in the iframe
would look like the rest of the canvas page)
Then in my controller, I have:
def upload_banner
@forum= Forum.find(params[:id])
render :layout => false
end
def upload_banner_post
@forum= Forum.find(params[:id])
@forum.save_banner(params[:file])
flash[:notice] = 'Your banner image was successfully uploaded.'
redirect_to(:action => :upload_banner, :id => @forum.id)
end
That's it. Works pretty good.
The only thing that I still cant get right is that I'd like to refresh
the page that contains the iframe to display something about the
banner after the upload, but I cant figure out how to ref any div's
from the these controller actions served into the iframe.
Hope that helps someone. Thx for the help, Mike and Joseph.
On Feb 4, 6:03 pm, Joseph Sofaer <joseph.sof...@gmail.com> wrote:
> That was the code I use.
> j.
>
> On Thu, Feb 4, 2010 at 5:59 PM, lunaclaire <szager...@gmail.com> wrote:
> > I've tried explicitly setting the action to submit directly back to my
> > servers, but the value I'm getting back from the file_field in the
> > params is still just a string with the filename in it and not a
> > StringIO object.
>
> > Any other ideas?
>
> > Joseph - It sounds like you've gotten something liek this to work...
> > If so, any code you can post showing what you did?
>
> > On Feb 4, 3:17 pm, Joseph Sofaer <joseph.sof...@gmail.com> wrote:
> >> I haven't use facebook_form_for but you might be able to overwrite the
> >> action. The other thing I had to do here was redirect explicitly back
> >> tohttp://apps.facebook.com/canvas_nameonthat request.
<h1>New Location</h1>
<% form_for(@location, :html => {:multipart => true}) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :address %> <br />
<%= f.text_field :address %>
</p>
<p><label for="upload_file">Upload image file (160x100 png)</label> :
<%= file_field 'upload', 'datafile' %></p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', locations_path %>
Thanks!
nnahum
> > > servers, but the value I'm getting back from thefile_fieldin the
Your problem is explained in the Facebook Documentation
http://wiki.developers.facebook.com/index.php/UsageNotes/Forms
"File uploads (that is, forms with enctype="multipart/form-data" and
<input type="file"> fields) will not work when the form is submitted
to a canvas URL. Instead, you need to submit file uploads directly to
your application and redirect back to a canvas page after the form is
processed."
So in order to get your form working in a FBML canvas page, you have
to point your form to your server url.
Something like this should do the tricks:
<% form_for(@location, locations_url(:canvas => false), :html =>
{:multipart => true}) do |f| %>
HTH,
--
Stéphane Akkaoui
http://imeuble.info
http://sociabliz.com
Le 24 févr. 10 à 07:22, nnahum a écrit :
The only problem I still have is that when I redirect to the server I
get error "ActionController::InvalidAuthenticityToken" because in my
ApplicationController I have a "protect_from_forgery"
The way I got around this was to include in my controller the
statement: "skip_before_filter :verify_authenticity_token" but
doesn't seems to me very elegant and may introduce some security
issues.
Any idea how to solve this authenticity token problem differently?
Thanks for the help!
nnahum
On Feb 24, 6:19 am, Stéphane Akkaoui <sakka...@gmail.com> wrote:
> Hi,
>
> Your problem is explained in the Facebook Documentation
>
> http://wiki.developers.facebook.com/index.php/UsageNotes/Forms
> "File uploads (that is, forms with enctype="multipart/form-data" and
> <input type="file"> fields) will not work when the form is submitted
> to a canvas URL. Instead, you need to submit file uploads directly to
> your application and redirect back to a canvas page after the form is
> processed."
>
> So in order to get your form working in a FBML canvas page, you have
> to point your form to your server url.
>
> Something like this should do the tricks:
>
> <% form_for(@location, locations_url(:canvas => false), :html =>
> {:multipart => true}) do |f| %>
>
> HTH,
>
> --
> Stéphane Akkaouihttp://imeuble.infohttp://sociabliz.com
> ...
>
> read more »