Sunday, October 4, 2009

[Rails] Re: Looking for a good resource on open-uri and FileUtils

Matt Jones wrote:
> You're probably better off starting by looking at Paperclip's S3
> support, which is logically closer to what you want to do.
>
> --Matt Jones
>
>
> On Oct 3, 10:15�am, James West <rails-mailing-l...@andreas-s.net>

Thank you Matt

I'm struggling to understand how the right_aws functionality works so I
can emulate it.

I have so far been able to implement the file_exist? function using
Net::FTP as follows

def exists?(style = default_style)
if original_filename
result = false
Net::FTP.open(domain_name) do |ftp|
#Need to implement domain_name, username and password
params.
#Probably best to emulate the way S3 module does this with a
yml file?
ftp.login('myusername', 'mypassword')
ftp.chdir(path(style))
begin
ftp.list(file_name)
true
rescue
#Need to extend this to raise all errors except file not
found
#Need to add specific check for file not found exception
result = false
# puts $!
end
end
end
end

I'm now looking at how I can code the to_file method
def to_file style = default_style
#This adds some kind of file stream (I think) to the
@queued_for_write hash array. I need to understand how to do this for a
NET::FTP connection.
@queued_for_write[style] || (File.new(path(style), 'rb') if
exists?(style))
end

I need to understand exactly what that is doing first though lol!
The flush_writes method should be pretty easy to implement. (I've worked
out how to use NET::FTP to make a directory and I'm sure the move and
chmod functions shouldn't be too difficult once I have the syntax for
those.

It's a huge learning curve for me but I'm getting there (slowly lol)

Still, any help or pointers would be really really appreciated
--
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@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate