Hey there, I''m new to Ruby on Rails. REALLY new. So far, I''ve managed to create an app, a controller, a route and I''ve managed to push this plain-text application to Heroku and deploy it there. The app is supposed to be a image uploading website, but instead of just storing the files on the file system, it should cURL the data to an image hoster''s API and return the image links. The main problems I''m facing are.. - I have never worked with MVC before - I''m pretty good with PHP but I completely suck at RoR - Storing files on Heroku''s file system is not allowed But how am I supposed to send files via cURL if I''m not allowed to store them on the file system? I''d be really grateful for any newbie-friendly advice on this. Thanks! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder
2010-Oct-31 19:48 UTC
Re: Rails newbie in dire need of help - File uploading
On Sun, Oct 31, 2010 at 11:45 AM, Mo3 <moritz.bruckner-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> But how am I supposed to send files via cURL if I''m not allowed to > store them on the file system?Look at the paperclip plugin; it can store uploaded files on Amazon S3, for instance, so even if you''re using some other storage it should give you some ideas. And FWIW I''ve used it for exactly your use case of deploying an app with an image (photo) upload to Heroku. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Moritz Bruckner
2010-Oct-31 19:57 UTC
Re: Rails newbie in dire need of help - File uploading
Hey Hassan, thanks for your reply. Paperclip looks interesting, but as of what Google says, it does not support cURL. I''ve already built a PHP image uploading API, and I want to use it with Rails. Is there any way to accomplish that or do I have to use PHP? Thanks -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder
2010-Oct-31 20:23 UTC
Re: Re: Rails newbie in dire need of help - File uploading
On Sun, Oct 31, 2010 at 12:57 PM, Moritz Bruckner <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> thanks for your reply. Paperclip looks interesting, but as of what > Google says, it does not support cURL. I''ve already built a PHP image > uploading API, and I want to use it with Rails. Is there any way to > accomplish that or do I have to use PHP?I''m not sure what you''re asking -- you want to use PHP in a Rails app that runs on Heroku? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Moritz Bruckner
2010-Oct-31 20:36 UTC
Re: Rails newbie in dire need of help - File uploading
No, i''ve already built a PHP script which can be used to upload images via HTTP POST. Now I''m trying to build some sort of graphical interface with Rails. Thus, this GUI app would need to use cURL to transfer the uploaded images to the API script. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder
2010-Oct-31 21:31 UTC
Re: Re: Rails newbie in dire need of help - File uploading
On Sun, Oct 31, 2010 at 1:36 PM, Moritz Bruckner <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> No, i''ve already built a PHP script which can be used to upload images > via HTTP POST. Now I''m trying to build some sort of graphical interface > with Rails. Thus, this GUI app would need to use cURL to transfer the > uploaded images to the API script.Sorry, I''m not following you at all. You have a Rails app on Heroku, and you want to store images for that app somewhere. So why not just use Paperclip? What''s the point of a separate upload mechanism? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
He has a PHP script that do "the thing" with amazon, but now he needs to tailor the Rails front-end app with that script through cURL. Right Moritz? You can execute cURL through Rails controllers like: class SomeController < ... def execute_my_php_script `curl http://myscript.moritz.com [options]` # you need to know how to run curl properly here end end> - I have never worked with MVC before > - I''m pretty good with PHP but I completely suck at RoRhttp://guides.rubyonrails.org/ Cheers! Jakub Godawa On 31 Paź, 22:31, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, Oct 31, 2010 at 1:36 PM, Moritz Bruckner <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > No, i''ve already built a PHP script which can be used to upload images > > via HTTP POST. Now I''m trying to build some sort of graphical interface > > with Rails. Thus, this GUI app would need to use cURL to transfer the > > uploaded images to the API script. > > Sorry, I''m not following you at all. > > You have a Rails app on Heroku, and you want to store images for > that app somewhere. So why not just use Paperclip? What''s the point > of a separate upload mechanism? > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > twitter: @hassan-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Moritz Bruckner
2010-Nov-01 06:01 UTC
Re: Rails newbie in dire need of help - File uploading
Yes exactly Jakub! The main problem is that Heroku (The hoster) does not allow any storing of files on their filesystem. Is there any other way? -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder
2010-Nov-01 15:47 UTC
Re: Re: Rails newbie in dire need of help - File uploading
On Sun, Oct 31, 2010 at 11:01 PM, Moritz Bruckner <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Yes exactly Jakub! The main problem is that Heroku (The hoster) does not > allow any storing of files on their filesystem. Is there any other way?Sorry, I still don''t get it. Why not just use Paperclip and forget about trying to kludge together something with PHP? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Moritz Bruckner
2010-Nov-01 15:59 UTC
Re: Rails newbie in dire need of help - File uploading
Hey there, okay once again :) I have already coded an image uploading API using PHP. This API can be accessed and used to upload images via cURL. For anyone interested, said API is public and fully working. Example: curl -F "@picture.jpg" http://api.imagecloud.us/?post=upload -> Will return a JSON-encoded response including image URL etc. To learn Rails, I want to create a graphical interface for this API. The problem is, the hoster I want to host this Rails GUI on does not allow the storing of files on the filesystem. Thus, putting the files in a temp directory on the filesystem and then transferring them is NOT an option. Sorry if my posts are a bit complicated, I''m from Germany and not really used to the english language. Thanks! -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2010-Nov-01 16:21 UTC
Re: Re: Rails newbie in dire need of help - File uploading
Could you use a form in your upload page that sets up a direct post to your imagecloud server, and sends along a unique identifier with that file? Then your imagecloud could post-back with the create file''s metadata, and your Rails app could listen for that and update the record asynchronously. Walter On Nov 1, 2010, at 11:59 AM, Moritz Bruckner wrote:> Hey there, > > okay once again :) > > I have already coded an image uploading API using PHP. This API can be > accessed and used to upload images via cURL. For anyone interested, > said > API is public and fully working. > > Example: curl -F "@picture.jpg" http://api.imagecloud.us/?post=upload > > -> Will return a JSON-encoded response including image URL etc. > > To learn Rails, I want to create a graphical interface for this API. > The > problem is, the hoster I want to host this Rails GUI on does not allow > the storing of files on the filesystem. Thus, putting the files in a > temp directory on the filesystem and then transferring them is NOT an > option. > > > Sorry if my posts are a bit complicated, I''m from Germany and not > really > used to the english language. > > Thanks! > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Moritz Bruckner
2010-Nov-01 16:43 UTC
Re: Rails newbie in dire need of help - File uploading
Ah that''d actually work, yeah! :) How would I set up such a form with Rails? -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Moritz Bruckner
2010-Nov-01 17:03 UTC
Re: Rails newbie in dire need of help - File uploading
Just found something on Ruby on Rails Guides: http://guides.rubyonrails.org/form_helpers.html#uploading-files Especially this code part: def upload uploaded_io = params[:person][:picture] File.open(Rails.root.join(''public'', ''uploads'', uploaded_io.original_filename), ''w'') do |file| file.write(uploaded_io.read) end end Wouldn''t you be able to, instead of file.write, transfer the files via cURL? -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2010-Nov-01 17:22 UTC
Re: Re: Rails newbie in dire need of help - File uploading
Yes, I think that''s what one of the other people on this list was saying in this thread. Ruby has cURL support baked in, and you can invoke it directly within your Rails app as long as you know the correct command format. Walter On Nov 1, 2010, at 1:03 PM, Moritz Bruckner wrote:> Just found something on Ruby on Rails Guides: > > http://guides.rubyonrails.org/form_helpers.html#uploading-files > > Especially this code part: > > def upload > uploaded_io = params[:person][:picture] > File.open(Rails.root.join(''public'', ''uploads'', > uploaded_io.original_filename), ''w'') do |file| > file.write(uploaded_io.read) > end > end > > Wouldn''t you be able to, instead of file.write, transfer the files via > cURL? > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2010-Nov-01 17:26 UTC
Re: Re: Rails newbie in dire need of help - File uploading
There are View Helper functions for building a generic form -- one not bound to a particular model instance. Have a look at the form_tag helper in the documentation. That can build any sort of form tag, pointed anywhere. Within it, you would put your unique identifier. You''re showing this form to an authenticated user, so you could do something where you stash that user''s id concatenated the current time in milliseconds or something like that. Persist that in your database, in the same table where you will eventually have all the details about your cloudy file. Then express that key as a hidden form element in your upload form. Walter On Nov 1, 2010, at 12:43 PM, Moritz Bruckner wrote:> Ah that''d actually work, yeah! :) > > How would I set up such a form with Rails? > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
instead of passing picture.jpg to imagecloud couldnt you pass [:person][:photo] to imagecloud? You shouldnt need to write anything, simply pass the raw data to imagecloud -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.