I''d like to decompress the contents of: http://host.com/file.zip in memory without having to download the file (e.g. `wget`) first. Suggestions? Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RobR wrote:> I''d like to decompress the contents of: > http://host.com/file.zip > > in memory without having to download the file (e.g. `wget`) first. > Suggestions?"Without having to download the file first" is an example of "premature optimization". It is the root of all evil. On any OS configured to be a server (as opposed to a wrist watch, for example) all memory and files map each other virtually. If you Net::HTTP read() that file to a file location, the OS will generally reserve a slot on the hard drive, then put the file into its matching memory location. In the next split microsecond, your code reads that file and unzips it, using only the memory image. If you then delete the file, it may never reach the hard drive. By that analysis, if you write simple code that downloads the file and hits it with common tools, you can finish your feature faster. However, there are also situations where you _don''t_ know which option is faster. Write the simpler code anyway, and then profile it to identify the real bottlenecks. They are invariably _not_ the places you would have guessed. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Those are good points. For now, I whipped up something simple which basically: begin `wget #{url}` `unzip #{localfilename}` # do stuff with file (FasterCSV) rescue ensure # delete local files end I don''t like relying on `` but sometimes it''s just too easy to pass up. My original message was trying to avoid `wget url` Thanks! On Apr 7, 9:53 pm, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> RobRwrote: > > I''d like to decompress the contents of: > >http://host.com/file.zip > > > in memory without having to download the file (e.g. `wget`) first. > > Suggestions? > > "Without having to download the file first" is an example of "premature > optimization". It is the root of all evil. > > On any OS configured to be a server (as opposed to a wrist watch, for example) > all memory and files map each other virtually. If you Net::HTTP read() that file > to a file location, the OS will generally reserve a slot on the hard drive, then > put the file into its matching memory location. > > In the next split microsecond, your code reads that file and unzips it, using > only the memory image. If you then delete the file, it may never reach the hard > drive. > > By that analysis, if you write simple code that downloads the file and hits it > with common tools, you can finish your feature faster. However, there are also > situations where you _don''t_ know which option is faster. > > Write the simpler code anyway, and then profile it to identify the real > bottlenecks. They are invariably _not_ the places you would have guessed.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---