Skip to main content

Multi File Upload for Plone

Project description

Makes Plone File Uploads easy

Multifileupload for Plone using uploadify

Plone integration

Upload folder tab action is install with default profile. You can install it via portal_quickinstaller or via Addons section in control panel.

Configuration

The following settings can be done in the site_properties. (please use string properties only!):

  • ul_auto_upload – true/false (default: false)

    Set to true if you would like the files to be uploaded when they are selected.

  • ul_allow_multi – true/false (default: true)

    Set to true if you want to allow multiple file uploads.

  • ul_sim_upload_limit – number 1-n (default: 4)

    A limit to the number of simultaneous uploads you would like to allow.

  • ul_queue_size_limit – number 1-n (default: 999)

    A limit to the number of files you can select to upload in one go.

  • ul_size_limit – size in bytes (default: empty)

    A number representing the limit in bytes for each upload.

  • ul_file_description – text (default: empty)

    The text that will appear in the file type drop down at the bottom of the browse dialog box.

  • ul_file_extensions – list of extensions (default: *.*;)

    A list of file extensions you would like to allow for upload. Format like *.ext1;*.ext2;*.ext3. FileDesc is required when using this option.

  • ul_button_text – text (default: BROWSE)

    The text you would like to appear on the default button.

  • ul_button_image – path to image (default: empty)

    The path to the image you will be using for the browse button. NOTE: If you are using a **different sized button image* you have to set ul_height and ul_width otherwise your ul_button_image will be stretched to the defaults (110x30)*

  • ul_hide_button – true/false (default: false)

    Set to true if you want to hide the button image.

  • ul_script_access – always/sameDomain (default: sameDomain)

    The access mode for scripts in the flash file. If you are testing locally, set to `always`.

  • ul_width – number (default: 110)

    The ul_width value which should be set when using a different sized ul_button_image

  • ul_height – number (default: 30)

    The ul_height value which should be set when using a different sized ul_button_image

  • ul_scale_image_size – x,y

    These two values define the max x,y size in pixels of the image. Scales an image down to at most ul_scale_image_size size preserving aspect ratio. Example: 800,600 to set a maximum size of 800x600 pixels

  • ul_content_field – Contenttype.field

    The uploaded file is included into the specific field from the specific Contenttype Example: File.file it uploads to field file from the contenttype File

Adding a custom File Mutator Utility

If you want to so some special handling for uploaded files before they get created in the portal, you can simply register a new utility providing the IFileMutator Interface.

Your utility will be called with file_name, file_data, content_type just before the content will be created in the portal.

Example

A simple utility which adds a “photo-” prefix to image filenames

configure.zcml:

<!-- An Utility to give images an "photo-" prefix -->
<utility component=".utility.prefix_image_filename"
         name="prefix-image-filename"/>

utility.py:

from zope import interface

def prefix_image_filename(file_name, file_data, content_type):
    """ Prefix all images with 'photo-<filename>'
    """
    # we only handle image files
    if not content_type.startswith("image"):
        return (file_name, file_data, content_type)

    if not file_name.startswith("photo"):
        file_name = "-".join(["photo", file_name])
    return (file_name, file_data, content_type)


interface.directlyProvides(prefix_image_filename,
                           IFileMutator)

Customization for specific BrowserLayer

If you have your own skin installed which is based on it’s own BrowserLayer (by default IThemeSpecific) and want to customize the look and feel of collective.uploadify’s you could override the upload view and/or the upload initialize callback view

  • Customize view template:

    <configure
        xmlns="http://namespaces.zope.org/zope"
        xmlns:browser="http://namespaces.zope.org/browser">
    
        ...
    
        <!-- Customize collective.uploadify upload template -->
        <browser:page
            for="collective.uploadify.browser.interfaces.IUploadingCapable"
            name="upload"
            template="templates/upload.pt"
            permission="cmf.AddPortalContent"
            layer=".interfaces.IThemeSpecific"
            />
    
    </configure>
  • Customize initialize template:

    from zope.i18n import translate
    from zope.component import getMultiAdapter
    from collective.uploadify.browser.upload import UploadInitalize
    from my.product import MyMessageFactory as _
    
    
    class MyCustomUploadInitalize(UploadInitalize):
        """ Initialize uploadify js
        """
    
        def upload_settings(self):
    
            portal_state = getMultiAdapter(
                (self.context, self.request), name="plone_portal_state")
    
            settings = super(MyCustomUploadInitalize, self).upload_settings()
            settings.update(dict(
                ul_height = 26,
                ul_width = 105,
                ul_button_text = translate(_('Choose images'), target_language= \
                                           self.request.get('LANGUAGE', 'de')),
                ul_button_image = portal_state.navigation_root_url() + \
                    '/button_upload.png',
            ))
    
            return settings

    Don’t forget to register the new upload initialize view for your themespecific browserlayer by using:

    <configure
         xmlns="http://namespaces.zope.org/zope"
         xmlns:browser="http://namespaces.zope.org/browser">
    
       ...
    
        <browser:page
            for="*"
            name="upload_initialize"
            class=".uploadify.MyCustomUploadInitalize"
            permission="cmf.AddPortalContent"
            layer=".interfaces.IThemeSpecific"
            />
    
    </configure>

collective.uploadify Installation

To install collective.uploadify into the global Python environment (or a workingenv), using a traditional Zope 2 instance, you can do this:

  • When you’re reading this you have probably already run easy_install collective.uploadify. Find out how to install setuptools (and EasyInstall) here: http://peak.telecommunity.com/DevCenter/EasyInstall

  • If you are using Zope 2.9 (not 2.10), get pythonproducts and install it via:

    python setup.py install --home /path/to/instance

into your Zope instance.

  • Create a file called collective.uploadify-configure.zcml in the /path/to/instance/etc/package-includes directory. The file should only contain this:

    <include package="collective.uploadify" />

Alternatively, if you are using zc.buildout and the plone.recipe.zope2instance recipe to manage your project, you can do this:

  • Add collective.uploadify to the list of eggs and zcml to install, e.g.:

    [buildout]
    ...
    eggs =
        ...
        collective.uploadify
    
    zcml =
        ...
        collective.uploadify
  • Re-run buildout, e.g. with:

    $ ./bin/buildout

Changelog

1.1 - 2012-10-11

  • moved to GitHub [ramonski]

  • Plone 4.3 compatibility [alert]

  • added italian translation. [keul]

  • cleanup egg format, removing bad zopeskel elements [keul]

  • added default genericsetup profile which adds folder tab for on each folder. [garbas]

1.0 - 2011-05-05

  • fixed the loss of File Extensions for Plone > 3.3.5 with IDNormalizer. Changed to use the IFileNameNormalizer Utility [jakke, ramonski]

  • added dutch translation [spereverde]

1.0rc5 - 2011-04-04

  • Support for different contenttypes [thor27]

  • added basque translation [erral]

  • added spain translation [macagua]

1.0rc4 - 2011-01-31

  • Added German translations [fRiSi]

  • Added Chinese (Taiwan) translations [marr]

  • Updated documentation to show Upload action on default pages too [fRiSi]

1.0rc3 - 2010-09-18

  • Fire Archetypes ObjectInitializedEvent for uploaded content. [hannosch]

  • Corrected i18n:domain in documented action and include its messages into the pot file. [hannosch]

  • Added a z3c.autoinclude entry point to avoid the need for a ZCML slug in Plone 3.3 and later. [hannosch]

  • changed permissions to cmf.AddPortalContent this fixes http://plone.org/products/collective.uploadify/issues/13 [ramonski]

  • mimetypes.guess_type(file_name) returns now an empty string if the type could not be guessed. This fixes an issue with the scale_image_size utility [ramonski]

  • documentation updated [ramonski]

1.0rc2 - 2010-08-03

  • Interface “IFileMutator” introduced – utilities which provide this interface can do some file mutations on the uploaded file before it get created as an content type [ramonski]

  • utility scale_image_size registered – this utility operates on images an can scale down the image size using PIL preserving the aspect ration from the input file [ramonski]

  • id chooser gets now called after the thread lock. This should fix #8 [ramonski]

  • added adapter for cStringIO.OutputType -> IBlobbable to be compatible with plone.app.blob. This adapter gets only registered when plone.app.blob is istalled. [ramonski]

  • use folder_url and remove is_folderish() and wf-state condition to make upload action show up on private folders or folders having a default page too (fixes http://plone.org/products/collective.uploadify/issues/12) [fRiSi]

  • i18n added + danish translation [stonor]

1.0rc1 - 2010-04-25

  • renamed resource swfobject.js to uploadify.swfobject.js. This fixes the name clash with quintagroup.portlet.cumulus [ramonski]

  • Added some basic tests to the package [ramonski]

  • Added queue size to the settings in UploadInitialize flash response to give users the possibility to customize their upload queue size. [zupo]

  • Documentation updates. Added new section about customize uploadify’s upload view and upload initialize view templates. [saily]

  • Added height and width to the settings in UploadInitialize flash response to give users the possibility to customize their uploadbuttons. [saily]

  • #9 fire ObjectModifiedEvent after upload of each item. (fixes http://plone.org/products/collective.uploadify/issues/9) [saily]

0.10 - 2010-03-16

0.9 - 2009-10-29

  • updated to Uploadify v2.1.0 [ramonski]

  • removed cgi parser for QUERY_STRING. Now we receive the data via POST [ramonski]

  • updated js, css and upload.pt [ramonski]

0.8 - 2009-10-27

  • added cgi parser for QUERY_STRING [seletz, ramonski]

  • added custom string encoder/decoder [seletz, ramonski]

  • fixed name chooser for german umlauts [ramonski]

0.7 - 2009-07-23

  • re-fixed name chooser …gnaarf [ramonski]

  • removed silly logging [ramonski]

0.6 - 2009-07-23

  • changed the paths to the resources in javascript from absolute to relative. This fixes some strange behaviour resulting in Uploadify - IOErrors [ramonski]

  • fixed #2 (AttributeError: aq_parent) – when doing uploads in the portal root [ramonski]

  • The upload folder can now be in private state as well. [ramonski]

0.5 - 2009-06-25

0.4 - 2009-06-23

  • added cancel button [ramonski]

  • uploadify settings can be set in site_properties [ramonski]

  • added a name chooser to avoid id clashes when uploading files [ramonski]

0.3 - 2009-06-22

  • fixed bug for M$ IE Browsers that the ‘Browse’ button not appear [ramonski]

  • changed permission for upload view to cmf.ModifyPortalContent [ramonski]

  • added onAllComplete handler which reloads the location and displays the uploaded files immediatly in the folder_listing macro [ramonski]

  • registered a browser view for the uploadify javascript initialization [ramonski]

  • registered a browser view for the uploadify upload action [ramonski]

  • removed unused code [ramonski]

0.2.2 - 2009-06-04

  • added missing .txt extension to MANIFEST.in **gnarf*, I hate setuptools! [ramonski]

0.2.1 - 2009-06-04

  • added missing MANIFEST.in file [ramonski]

0.2 - 2009-06-04

  • removed gs profile [ramonski]

  • added css styles for buttons [ramonski]

  • fixed bug with upper case file extensions [ramonski]

0.1 - 2009-04-30

  • Initial release [ramonski]

Contributors

Ramon Bartl, Author

Stefan Eletzhofer, InQuant GmbH

Harald Friessnegger, Webmeisterei GmbH

Daniel Widerin, Kombinat Media Gestalter GmbH

Nejc Zupan, NiteoWeb Ltd.

Jan Van Hees, K.U.Leuven

Kim Paulissen, K.U.Leuven

Rok Garbas, http://www.garbas.si

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

collective.uploadify-1.1.tar.gz (60.8 kB view details)

Uploaded Source

File details

Details for the file collective.uploadify-1.1.tar.gz.

File metadata

File hashes

Hashes for collective.uploadify-1.1.tar.gz
Algorithm Hash digest
SHA256 a8207d1de3810871a836b2f8cca893e0beb995ba739c5fa9edcd6b37bc2a73f0
MD5 d4226963dfc9494ae814cacbdf520a31
BLAKE2b-256 13aac10405fddea24c37d62f6ef8dd80c89db67b421161676916128bff2ea78b

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