addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

how to post image data over using ActiveResource

From: Elliott B.
Sent on: Thursday, June 5, 2008 1:22 PM
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.



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