Retrieve a file from inside a ZIP file, over the network! Pretty sweet, eh?
PINCHSome crazyHTTP ZIP Magic
View Slide
@peterhellberg
I’m a Senior SystemsArchitect at Athega(where I build stuff in Ruby)⃔I’m also the ownero Code7 Interactive(where I build stuff in Ruby)⃕
Retrieve a ile rominside a ZIP ile,over the network!Pretty sweet, eh?
require 'pinch'url = 'http://peterhellberg.github.com/pinch/test.zip'data = Pinch.get(url, 'data.json')# Do something with the dataHow?
Now, let’s goback in⏰
’89APPNOTE.TXThttp://PKWARE.com/documents/casestudies/APPNOTE.TXT
FILE ENTRY 1 FILE ENTRY 2 CENTRAL DIRECTORY END OF CENTRAL DIRECTORYSignature 0x06054b50ZIP File Format
Pinch does NOTunderstand theZIP File Format
HTTP/1.114.16 Content-Range❤ || ☠
1 HEAD Total ile size2 GET Last 4096 bytes (End of Central Directory)3 GET Central Directory start → Central Directory start + size4 GET File offset → File offset + (compressed) sizeHTTP Requests
String#unpackZlib::In lateArray#pack
gem install pinch
github.com/peterhellberg/pinch
@peterhellbergpeterhellberg.infogit.io/peterhellberg