Giter VIP home page Giter VIP logo

zip-service's Introduction

zip-service

This is an HTTP service which downloads files and streams them back to you as a single zip file.

The request body looks like this:

[
  {
    "filename": "foo.jpg",
    "url": "https://www.example.com/blahblahblah.jpg"
  },
  {
    "filename": "bar.jpg",
    "url": "https://s3.amazon.com/thisisanexample/blah.jpg"
  },
  // etc...
]

The response is a zip file containing all the indicated files.

Instructions

  • install the Rust tool chain (I recommend rustup: https://rustup.rs/)
  • (if compiling on macOS) ensure you have the command line build tools: xcode-select install
  • execute cargo run --release and go get some coffee. when you get back the server should be running
  • make a request with your favorite http client. examples:
curl http://localhost:3000/ \
  -d '[{"url": "https://media.giphy.com/media/3oz8xD0xvAJ5FCk7Di/giphy.gif", "filename": "pic001.gif" }]' \
  -H "Content-Type: application/json" \
  > archive.zip

curl http://localhost:3000/ \
  -d "@examples/small_example.json" \
  -H "Content-Type: application/json" \
  > archive.zip

curl http://localhost:3000/ \
  -d "@examples/huge_example.json" \
  -H "Content-Type: application/json" \
  > archive.zip

Design notes

My primary goal was to keep the memory per request bounded no matter how many files the user asks for or the size of the files. To accomplish this, files are retrieved one at a time. As the file data arrives, it is immediately compressed and sent to the response stream.

TODO

  • write tests
  • add better error handling
  • reduce allocations
  • implement more of the zip spec, in particular zip64 extensions and different compression options

zip-service's People

Contributors

jgraydus avatar

Watchers

 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.