hey, i have this code for savinf a file to disk. def SaveFiletoDisk(file, object) folder = "mediastorage" root_dir = Dir.new(folder) current_dir = folder + "/" + object.id.to_s Dir.mkdir(current_dir) File.open(current_dir, "wb") { |f| f.write(file.read) } return current_dir end and i get errors like: Permission denied - mediastorage/12 how can i set the permission for the folder "12" so that i can save a file in it? Thx -- 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-/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 -~----------~----~----~----~------~----~------~--~---
> how can i set the permission for the folder "12" so that i can save a > file in it?Hi Nick, How you do it is OS specific, but what you do is generally one of the following. You can ensure that your web server runs under the same user id as the owner of that directory. You can also set up a group, give that directory group write access, and then ensure that the user id that your web server is running under is in the same group as the owner of that directory. (I typically use this approach.) Finally, you can give that directory world write access. (You might also consider using an absolute path. Not that that will fix the permissions issue.) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Zachary Holt wrote:>> how can i set the permission for the folder "12" so that i can save a >> file in it? > > Hi Nick, > > How you do it is OS specific, but what you do is generally one of the > following. > > You can ensure that your web server runs under the same user id as the > owner of that directory. You can also set up a group, give that > directory group write access, and then ensure that the user id that > your web server is running under is in the same group as the owner of > that directory. (I typically use this approach.) Finally, you can > give that directory world write access. > > (You might also consider using an absolute path. Not that that will > fix the permissions issue.)it doesnt seem to work :s:s Permission denied - F:/rails_template_0.0.2/mediastorage/38/ i use win xp i can create \mediastorage i can create \mediastorage\38 but not the file itself :s:s Can u help me? Thx -- 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-/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 -~----------~----~----~----~------~----~------~--~---
On Sep 1, 2006, at 10:41 AM, Nick Brutyn wrote:> def SaveFiletoDisk(file, object) > folder = "mediastorage" > root_dir = Dir.new(folder) > current_dir = folder + "/" + object.id.to_s > Dir.mkdir(current_dir) > File.open(current_dir, "wb") { |f| f.write(file.read) } > return current_dir > end > > Can u help me?It looks like you''re naming the directory to write to, but you''re not naming the file. Does this help? File.open("#{current_dir}/filename.ext", "wb") { |f| f.write (file.read) } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Zachary Holt wrote:> On Sep 1, 2006, at 10:41 AM, Nick Brutyn wrote: >> def SaveFiletoDisk(file, object) >> folder = "mediastorage" >> root_dir = Dir.new(folder) >> current_dir = folder + "/" + object.id.to_s >> Dir.mkdir(current_dir) >> File.open(current_dir, "wb") { |f| f.write(file.read) } >> return current_dir >> end >> >> Can u help me? > > It looks like you''re naming the directory to write to, but you''re not > naming the file. Does this help? > > File.open("#{current_dir}/filename.ext", "wb") { |f| f.write > (file.read) }thx that works! :) -- 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-/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 -~----------~----~----~----~------~----~------~--~---