Skip to main content
Latest PyPI version Number of PyPI downloads Test cone.fileupload

This package integrates jQueryFileUpload in cone.

Currently, version 10.32.0 is included.

Included files of jQuery File Upload:

  • jquery.iframe-transport.js

  • jquery.fileupload.js

  • jquery.fileupload-process.js

  • jquery.fileupload-ui.js

  • jquery.fileupload-validate.js

Additionally, v3.20.0 of Javascript-Templates is included.

Usage

Since cone.app not knows about the underlying data, cone.fileupload only provides an abstract server implementation.

So first we need to provide a model.

from cone.app.model import BaseNode
from pyramid.security import ALL_PERMISSIONS
from pyramid.security import Allow
from pyramid.security import Deny
from pyramid.security import Everyone

ACL = [
    (Allow, 'role:manager', ['add', 'delete']),
    (Allow, Everyone, ['login']),
    (Deny, Everyone, ALL_PERMISSIONS),
]

class Container(BaseNode):
    __acl__ = ACL

    def __call__(self):
        """Persistence happens here.
        """

class File(BaseNode):
    __acl__ = ACL

    # allow setting any value types
    child_constraints = None

Now we need to provide a concrete FileUploadHandle implementation for our model.

from cone.fileupload.browser.fileupload import FileUploadHandle
from pyramid.view import view_config

@view_config(
    name='fileupload_handle',
    context=Container, # <- here the view gets bound to our model
    accept='application/json',
    renderer='json',
    permission='add')
class ContainerFileUploadHandle(FileUploadHandle):

    def create_file(self, stream, filename, mimetype):
        # this function gets called for persisting uploaded files
        file = self.model[filename] = File()
        file['body'] = stream.read()
        return {
            'name': filename,
            'size': len(file['body']),
            'view_url': '/{0}'.format(file.name),
            'download_url': '/{0}/download'.format(file.name),
            'delete_url': '/{0}/filedelete_handle'.format(file.name),
            'delete_type': 'POST',
        }

    def read_existing(self):
        # this function gets called for initial reading of existing files
        files = list()
        for node in self.model.values():
            files.append({
                'name': node.name,
                'size': len(node['body']),
                'view_url': '/{0}'.format(node.name),
                'download_url': '/{0}/download'.format(node.name),
                'delete_url': '/{0}/filedelete_handle'.format(node.name),
                'delete_type': 'POST',
            })
        return files

Optionally we might want to provide a custom fileupload tile for our model.

from cone.tile import tile
from cone.fileupload.browser.fileupload import FileUploadTile

@tile(
    name='fileupload',
    path='cone.fileupload:browser/fileupload.pt',
    interface=Container,
    permission='add')
class ContainerFileUploadTile(FileUploadTile):
    accept_file_types = r'/(\.|\/)(gif|jpg)$/i'

The file upload actions are either rendered as dedicated tile by name fileupload_toolbar or integrated into the context menu. If it’s desired to display the action in the context menu, fileupload_contextmenu_actions flag must be set on model properties.

Contributors

  • Robert Niederreiter

Changes

2.1.0 (2026-11-09)

  • filedelete_handle only accepts POST requests. A FileUploadHandle returning delete_type needs to return POST. [rnix]

2.0.1 (2026-10-31)

  • Extend the JS tests to 100 % coverage, all modules including bundles are loaded by the tests now. [rnix]

  • Lint and format the JS code with biome. make check runs biome check, make format runs biome check --write (see include.mk). Behavior unchanged. [rnix]

  • JS tooling: Commit pnpm-lock.yaml. Upgrade @web/test-runner to 1.0 and run the JS tests headless in Chromium via Playwright, installed in the JS CI workflow. Pin patched versions of vulnerable transitive dependencies via pnpm.overrides. [rnix]

  • Sort the imports with ruff (one per line, from imports first, no sections) and format the code with ruff format (90 characters per line, single quotes). [rnix]

  • Add import sorting (I rules) and the formatter settings to the ruff configuration in pyproject.toml. [rnix]

2.0.0 (2026-10-24)

  • Drop the Python 2 StringIO import fallback in tests. [rnix]

  • Modernise the code ruff flags as outdated: u'' prefixes, class X(object), .format() over f-strings. Behaviour unchanged. super(Class, self) is kept, see cone.app. [rnix]

  • Add qa.ruff domain to Makefile and pin the ruff rule selection in pyproject.toml, make check runs ruff check. [rnix]

  • Pin setuptools<82.0.0 in mx.ini. pyramid 2.0.2 still imports pkg_resources, which setuptools 82 removed. [rnix]

  • Bootstrap 5 styles.

1.1.0 (2026-02-03)

  • Refactor package layout to use pyproject.toml and implicit namespace packages. [rnix]

  • Setup Makefile. [lenadax]

  • Run tests with pytest. [lenadax]

1.0a1 (2023-05-15)

  • Use webresource for resource registration. [rnix]

  • Replace deprecated use of allow_non_node_children by child_constraints. [rnix]

0.8 (2025-10-25)

  • Pin upper versions of dependencies. [rnix]

  • Replace deprecated use of allow_non_node_children by child_constraints. [rnix]

0.7 (2022-01-19)

  • Modernize JavaScript setup.

  • Add i18n_messages_src, upload_template_src and download_template_src attributes to FileUploadTile.

  • Add optional download_url to file data dict.

  • Remove thumbnailUrl from file data dict.

Breaking Changes

  • Rename url to view_url in file data dict.

  • Rename deleteUrl to delete_url in file data dict.

  • Rename deleteType to delete_type in file data dict.

0.6 (2021-11-21)

  • Fileupload actions optionally work from contextmenu. [rnix]

  • Move button toolbar into dedicated tile for customization. [rnix]

  • Reduce included files and plugins of jquery fileupload to required ones. [rnix]

  • Update jquery fileupload to version 10.32.0. [rnix]

0.5 (2021-11-08)

  • Rename deprecated allow_non_node_childs to allow_non_node_children in tests and documentation. [rnix]

0.4 (2020-05-30)

  • Initial pypi release [rnix]

0.3

  • Python 3 compatibility. [rnix]

  • Convert doctests to unittests. [rnix]

  • Use cone.app.main_hook decorator. [rnix]

  • Move resource registration to main hook. [rnix]

  • Upgrade to cone.app 1.0b1. [rnix]

0.2

  • Code organization. [rnix]

0.1

  • Make it work [rnix]

License

Copyright (c) 2013-2021, BlueDynamics Alliance, Austria Copyright (c) 2021-2025, Cone Contributors All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Metadata

Release files for cone.fileupload 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cone.fileupload 2.1.0
File Size Uploaded Provenance Actions
cone_fileupload-2.1.0.tar.gz 165.6 kB Without provenance Details for cone_fileupload-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cone.fileupload 2.1.0
File Interpreter ABI Platform Actions
cone_fileupload-2.1.0-py3-none-any.whl Python 3 none any Details for cone_fileupload-2.1.0-py3-none-any.whl

Total release size: 340.0 kB

Release files / cone_fileupload-2.1.0.tar.gz

Download URL cone_fileupload-2.1.0.tar.gz
Size 165.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fb900c0c403f48c3d9e80d0a7fc6732e69b5728715699aeb46e265034b953779
BLAKE2b-256 checksum
How to use checksums
c06778a3fadc5ff3740b577ca511f8fc3a0d26fa6017439ad6e9136b4c02b4e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / cone_fileupload-2.1.0-py3-none-any.whl

Download URL cone_fileupload-2.1.0-py3-none-any.whl
Size 174.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc3f6732ffc4b9a485916d58716fbaba7015d6e8d18ceb583e51eaeb6a0a4ebe
BLAKE2b-256 checksum
How to use checksums
f76600a89d1b9562a1ee9b46479a70f73b3681ba99e326be265674d303bdec51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for cone.fileupload 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page