addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupsimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1outlookpersonJoin Group on CardStartprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Re: [ruby-81] how to post image data over using ActiveResource

From: Keli K.
Sent on: Thursday, June 5, 2008 1:50 PM
Hi Elmo,

here is an example that helped me:

http://khamsouk.souvanlasy.com/2007/5/1/ajax-file-uploads-in-rails-using-attachment_fu-and-responds_to_parent


<%= error_messages_for :asset %>
<% form_for(:asset, :url => assets_path, :html => { :multipart => true }) do |form| %>
<p>
<label for="uploaded_data">Upload a file:</label>
<%= form.file_field :uploaded_data %>
</p>
<p>
<%= submit_tag "Create" %>
</p>
<% end %>



I hope this helps,

Keli


On Thu, Jun 5, 2008 at 1:43 PM, elmo <[address removed]> wrote:
Hello Ian,

Thanks for your reply. 

I've got to the multi-part mime POST, would you know of a good  example I could follow for doing so?

Best,
Elliott

 



----- Original Message ----
From: Ian Smith-Heisters <[address removed]>
To: [address removed]
Sent: Thursday, June 5,[masked]:35:36 PM
Subject: Re: [ruby-81] how to post image data over using ActiveResource

I've had great success encoding images using Base64.encode, pushing
them into an XML element and transferring them that way. It's slow
both in the encoding and in the use of bandwidth, but it's nice in
that the data is embedded directly into the XML. Otherwise, you'll
need to do a multipart mime POST.

On Thu, Jun 5, 2008 at 1:22 PM, elmo <[address removed]> wrote:
> Hello folks,
> I'd appreciate a tip with a problem I'm facing:
> I've got an REST service that I'd like to be able to POST image data to.
> On the 'client' application I have:
> model:
> class Asset < ActiveResource
>        self.site += "/posts/:post_id"
> end
> controller:
> I'd like t o do the following:
>  @asset = Asset.new( :post_id => @post.id )  <<<----is this the correct way
> to initialize?
>  @asset.uploaded_data = params[:asset] <<-------i know it can't be this easy
>  @asset.save
>
> On the REST service application, the asset model is an attachement_fu -ized
> model:
> model
> class Asset < ActiveRecord::Base
>      has_attachment :content_type => :image,
>                  :storage => :file_system,
>                  :max_size => 500.kilobytes,
>                  :thumbnails => { :thumb => '100x100>' },
>                  :processor => :rmagick
>    validates_as_attachment
> end
> controller:
>  @asset = @post.assets.new(params[:asset])
> I get:
> NoMethodError (undefined method `content_type' for
> #<HashWithIndifferentAccess:0x542a360>):
>    /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:294:in
> `uploaded_data='
>
> Questions:
> 1. How do I correctly pass the image data to the REST controller via
> XML/ARES?
> 2. Do I have to set some headers?
> Thanks for your consideration.
>
>
>
>
>
>
> --
> Please Note: If you hit "REPLY", your message will be sent to everyone on
> this mailing list ([address removed])
> This message was sent by elmo ([address removed]) from The East Bay
> Ruby Meetup Group.
> To learn more about elmo, visit his/her member profile
> To unsubscribe or to update your mailing list settings, click here
>
> Meetup Support: [address removed]
> 632 Broadway New York NY 10012 USA



--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
http://ruby.meetup.com/81
This message was sent by Ian Smith-Heisters ([address removed]) from The East Bay Ruby Meetup Group.
To learn more about Ian Smith-Heisters, visit his/her member profile: http://ruby.meetup.com/81/members/5024559/
To unsubscribe or to update your mailing list settings, click here: http://www.meetup.com/account/?tab=comm

Meetup Support: [address removed]
632 Broadway New York NY 10012 USA






--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by elmo ([address removed]) from The East Bay Ruby Meetup Group.
To learn more about elmo, visit his/her member profile
To unsubscribe or to update your mailing list settings, click here

Meetup Support: [address removed]
632 Broadway New York NY 10012 USA

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy