Hi together I need a REST webservices, through which I can upload pictures from a .NET client Desktop-Tool. Here the "upload"-code-snipped from the .NET client tool: .... Dim imageBytes() As Byte imageBytes = ImageHelper.Image2ByteArray(image, format) responseBytes = client.UploadData(url, "POST", imageBytes) ... Now my question is: how can i access the uploaded picture in my Controller? Because there is no form and no fieldname for the picture I don''t know how to access it... Can anybody help me? Greets sigma --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
In your controller you have to read the input sent using the stdinput
attribute. The example below I''m using CURL to send an image to my
uploads_controller to simulate your REST webservice:
# Sending data via CURL
cat photo.jpg | curl -X POST -H ''Content-type: image/jpeg --data-
binary @- "http://localhost:5000/uploads/create"
# Reading the content and storing to a file
class UploadsController < ApplicationController
def create
File.open("assets/photo.jpg", "wb") {|f| f <<
request.stdinput.read}
render :text => "image upload sent\n"
end
end
--
Thiago Jackiw
http://www.railsfreaks.com
On May 5, 12:32 pm, sigma
<christoph.thom...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi together
>
> I need a REST webservices, through which I can upload pictures from
> a .NET client Desktop-Tool.
>
> Here the "upload"-code-snipped from the .NET client tool:
>
> ....
> Dim imageBytes() As Byte
> imageBytes = ImageHelper.Image2ByteArray(image, format)
> responseBytes = client.UploadData(url, "POST", imageBytes)
> ...
>
> Now my question is: how can i access the uploaded picture in my
> Controller? Because there is no form and no fieldname for the picture
> I don''t know how to access it...
>
> Can anybody help me?
>
> Greets
> sigma
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
You''re my hero ;-) It works now... I only had to change request.stdinput.read to request.raw_post Thank you --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey no problem. Yeah you could also use request.raw_post, guess I forgot to mention hehe. -- Thiago Jackiw http://www.railsfreaks.com On May 6, 12:25 am, sigma <christoph.thom...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You''re my hero ;-) It works now... > I only had to change request.stdinput.read to request.raw_post > > Thank you--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey no problem. Yeah you could also use request.raw_post, guess I forgot to mention it hehe -- Thiago Jackiw http://www.railsfreaks.com On May 6, 12:25 am, sigma <christoph.thom...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You''re my hero ;-) It works now... > I only had to change request.stdinput.read to request.raw_post > > Thank you--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry for the double post, was having a connection problem. On May 6, 12:45 am, Thiago Jackiw <tjac...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey no problem. Yeah you could also use request.raw_post, guess I > forgot to mention it hehe > > -- > Thiago Jackiwhttp://www.railsfreaks.com > > On May 6, 12:25 am, sigma <christoph.thom...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > You''re my hero ;-) It works now... > > I only had to change request.stdinput.read to request.raw_post > > > Thank you--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---