Hi, I am trying to validate uploads on an application where the uploaded file is a zipped archive, and I want some validation to include acceptable datestamps within the zipfile, When I open a zip, with invalid datestamp, I receive the console output: ''Invalid date/time in zip entry'' Which is great, but I want to be able to extract this information and use it to reject the upload, but I can''t seem to find a method which will allow me to extract this information from the zip. Does anybody know of a method I can use which will return the date/ time stamp of the zip file, or return the Rescue statement above if it is invalid? Thank you Pete -- 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.
On Sun, Oct 10, 2010 at 10:54 AM, Pete <peterhughes0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Which is great, but I want to be able to extract this information and > use it to reject the upload, but I can''t seem to find a method which > will allow me to extract this information from the zip.> Does anybody know of a method I can use which will return the date/ > time stamp of the zip fileInstall the rubyzip gem. -- 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.
Thanks, rubyzip gem installed, but I am still having the same problems - I am trying to use the methods (mtime etc) to access the timestamp information that is initially being returned as the rescue statement ''Invalid date/time in zip entry'' All I need to do is be able to access this ''invalid date/time'' entry, but none of the ''time'' methods seem to return this. This message is only shown upon opening the zip file - is there a time method I can use on the zip itself, rather than on the contents which might show me the invalid timestamp? Thanks again Pete -- 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.
On Mon, Oct 11, 2010 at 2:04 AM, Pete <peterhughes0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> but I am still having the same problems - I am trying to use the > methods (mtime etc) to access the timestamp information that is > initially being returned as the rescue statement ''Invalid date/time in > zip entry''What exactly is it that''s returning that statement?> All I need to do is be able to access this ''invalid date/time'' entry, > but none of the ''time'' methods seem to return this.I''m sure they don''t. If, as I suspect, you''re getting that message when you use ''unzip'' from the command line, that message is coming from that specific program. I would imagine you''ll have to write your own method to examine the timestamps of the files in the zip and decide whether they meet your criteria for "invalid". FWIW, -- 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.
The line of output is acutally in the rubyzip.rb file itself, line 584 - def set_time(binaryDosDate, binaryDosTime) @time = Time.parse_binary_dos_format(binaryDosDate, binaryDosTime) rescue ArgumentError puts "Invalid date/time in zip entry" end end The Timestamp in the Zip file, is causing the rescue statement to be output after the file has been opened, but I would like to be able to ''catch'' this if at all possible, Thanks Pete On 11 Oct, 22:37, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mon, Oct 11, 2010 at 2:04 AM,Pete<peterhugh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > but I am still having the same problems - I am trying to use the > > methods (mtime etc) to access the timestamp information that is > > initially being returned as the rescue statement ''Invalid date/time in > > zip entry'' > > What exactly is it that''s returning that statement? > > > All I need to do is be able to access this ''invalid date/time'' entry, > > but none of the ''time'' methods seem to return this. > > I''m sure they don''t. If, as I suspect, you''re getting that message when > you use ''unzip'' from the command line, that message is coming from > that specific program. > > I would imagine you''ll have to write your own method to examine the > timestamps of the files in the zip and decide whether they meet your > criteria for "invalid". > > FWIW, > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I had the same problem; in my case it arose from treating the file reference returned from Zip::ZipFile.each{} as a string (like Dir.each{}) instead of whatever it actually is. Add ".name" where you need the file name. This code gave the error: Zip::ZipFile.open(file) { |zip_file| zip_file.each { |f| myLogger("Inspecting file #{f}") next unless f.file? ... ...and this worked: Zip::ZipFile.open(file) { |zip_file| zip_file.each { |f| myLogger("Inspecting file #{f.name}") next unless f.file? ... Cheers, BillR -- 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.