Skip to main content

Zip file extracter for Plone

Project description

Introduction

This package is used to extract files and directories from a zip file and add them to a Plone application.

The module provides a view showing the contents of the zip file and the associated file sizes. From the view you can extract everything from the file or select a subset of elements to extract.

The extraction itself is designed to be as safe as possible, notably:

  • Safe against zip bombs

    • Checks announced size of files to extract (from zip file header) and stops extracting if that size is exceeded.

    • We can also set a total maximum data volume allowed to be extracted.

  • Safe against extraction outside of destination folder.

  • Controlled RAM usage. Uses a buffer to write to a temporary file.

  • Handles things like zip file containing several files with the same name.

Compatibility

Plone 4.3.x

Implementation

  • The ftw.zipextract.zipextracter.ZipExtracter class handles the extraction from the zip file.

  • The ftw.zipextract.browser.zipextract_view.ZipExtractView is used for the rendering of the extraction view. It is registered as zipextract and will be applied on its context.

Handling and creation of files and folders depends on the context and the content types. To handle this, 4 interfaces are used:

  • ftw.zipextract.interfaces.IFile defines a few methods for file handling and notably an is_zip method used to determine whether the extraction can be used on a given file or not.

  • ftw.zipextract.interfaces.IFactoryTypeDecider decides which factory type information to use for creating folders or files from the zip within a specific container.

    • defines a get_file_fti method

    • defines a get_folder_fti method

  • ftw.zipextract.interfaces.IFileCreator defines a create method to create a new file

  • ftw.zipextract.interfaces.IFolderCreator defines a create method to create a new folder

Adapting the package to your application

To adapt this package to other applications you might need to write adapters for the 4 interfaces described above. ftw.zipextract provides default implementations for Dexterity types and Archetypes for all 4 interfaces.

Installation

  • Add the package to your buildout configuration:

[instance]
eggs +=
    ...
    ftw.zipextract

Install the generic setup profile of ftw.zipextract.

Development

  1. Fork this repo

  2. Clone your fork

  3. Shell: ln -s development.cfg buildout.cfg

  4. Shell: python bootstrap.py

  5. Shell: bin/buildout

Run bin/test to test your changes.

Or start an instance by running bin/instance fg.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ftw.zipextract-1.1.4.tar.gz (23.7 kB view details)

Uploaded Source

File details

Details for the file ftw.zipextract-1.1.4.tar.gz.

File metadata

  • Download URL: ftw.zipextract-1.1.4.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10

File hashes

Hashes for ftw.zipextract-1.1.4.tar.gz
Algorithm Hash digest
SHA256 9a5ebc4b2ac9868cd9945f9775c199e5f44d39874b8ddb0d98bcd970d4602c56
MD5 03387dd1c9da6f119111d16b9703c09d
BLAKE2b-256 df9c0d9465f818e729153ad7aa1d8d46b5da892b169c5345a44475dbbad1e930

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page