Git Product home page Git Product logo

zipping's Introduction

zipping

Gem Version

This gem is for compressing files as a zip and outputting to a stream (or a stream-like interface object). The output to a stream proceeds little by little, as files are compressed.

Getting Started

Add the following line to your Gemfile:

gem 'zipping'

Usage

simple:

require 'zipping'

Zipping.files_to_zip my_stream, '/path/to/file'

You can pass multiple files.

Zipping.files_to_zip my_stream2, ['/path/to/file', '/another/path']

If you pass a folder, zipping compresses all files in the folder.

Zipping.files_to_zip my_stream3, ['/path/to/folder', '/path/to/other/file']

For example, you have files below:

/text/foo.txt
/text/bar/baz.txt
/images/abc.png

and you run command:

file = File.open '/my.zip', 'wb'
Zipping.files_to_zip file, ['/text', '/images/abc.png']
file.close

Then, you get a zip file, and you find entries below in it.

text/
text/foo.txt
text/bar/
text/bar/baz.txt
abc.png

To get binary data of zip instead of saving as a file, prepare an 'ASCII-8bit'-encoded empty String object.

zip_data = ''.force_encoding('ASCII-8bit')
Zipping.files_to_zip zip_data, ['/text', '/images/abc.png']

Then, you get zip binary data in zip_data.


Copyright Nekojarashi Inc.

zipping's People

Contributors

misakik avatar s-shitasako avatar tagty avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.