Coder Social home page Coder Social logo

isabella232 / zipstream Goto Github PK

View Code? Open in Web Editor NEW

This project forked from esri/zipstream

0.0 0.0 0.0 146 KB

Microservice for zip file downloads constructed on-the-fly from S3 content

License: Apache License 2.0

Rust 96.29% Dockerfile 3.71%

zipstream's Introduction

zipstream

A microservice to serve ZIP archives generated on-the-fly from files on Amazon S3.

It works by forwarding requests to an upstream HTTP server that returns a JSON manifest of files to include, then generates the archive by requesting content from S3 as the download progresses.

Features:

  • Zip64 support (archives and files > 4GiB)
  • Content-length headers for an accurate download progress bar
  • Range requests so that partial or failed downloads can be resumed

In order to compute the length ahead of time and to support seeking to any position, it imposes a few limitations:

  • Size of each archive member and its CRC32 must be known ahead of time and included in the manifest.
  • Archive members are not compressed. (If serving files that are already compressed, ZIP compression would not have any benefit anyway)

Usage

zipstream --listen <ip:port> --upstream <URL> --header-value <header-value> --strip-prefix <strip-prefix> 
  • --listen <ip:port> IP:port to listen for HTTP connections [default: 127.0.0.1:3000]
  • --upstream <URL> Upstream server that provides zip file manifests
  • --header-value <header-value> Value passed in the X-Via-Zip-Stream header on the request to the upstream server [default: true]
  • --strip-prefix <strip-prefix> Remove a required prefix from the URL path before proxying to upstream server [default: '']

Incoming requests are proxied to the upstream server. If the response from the upstream server does not include the X-Zip-Stream: true header, the response is passed through to the client as-is. When this header is included, the response parsed as a manifest of files to include in a zip file which is streamed back to the client.

The manifest is JSON in the following format:

{
  "filename": "test.zip", // The download filename returned in a Content-disposition: attachment header
  "entries": [
    {
      "archive_name": "file1.jpg", // The file name as it will be included in the zip
      "length": 7293198, // Exact length in bytes
      "crc": 2113672619, // CRC32 checksum of the file content
      "source": "s3://bucketname/objectpath", // Source location of the file on S3
      "last_modified": "2020-04-24T19:12:24.268Z" // Timestamp to use as the last modified time in the archive
    },
    ...
  ]
}

zipstream's People

Contributors

dependabot[bot] avatar kevinmehall 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.