Export images over WebDAV in Plone 5

Hello.
I would like to export folders with images from a Plone website (Plone version 5.1.5).
Now when I connect to Plone via webdav, I have access to the files. However, under Dexterity, content is transferred in RFC 2822 format.
But I need the images in the original format (mostly jpeg)
In the documentation of Dexterity I read that this behavior can be changed by the adapters IRawWriteFile and IRawReadFile.
But as far as I understand, this has to be done with coding.
Is there a way to export images in the original format from an existing Plone instance without coding?
With Archetypes it was possible to get images and files as binary files (.jpg, .pdf) and not the text representation as RFC 2822
Thank you vey much in advance

Long time (11 years) ago, I made a product that exported images.
I have not used it 'in ages', but it should probably still work (note the part in changelog about exporting scales / Desxterity, although from your question that does not matter (?)).

Thank you very much. But unfortunately I get the following error message when I install the package via buildout:

Traceback (most recent call last):
File "/home/paul/plone_sites/plone/zinstance/parts/instance/bin/interpreter", line 291, in
exec(compile(__file__f.read(), file, "exec"))
File "/home/paul/plone_sites/plone/buildout-cache/eggs/Zope2-2.13.27-py2.7.egg/Zope2/Startup/run.py", line 76, in
run()
File "/home/paul/plone_sites/plone/buildout-cache/eggs/Zope2-2.13.27-py2.7.egg/Zope2/Startup/run.py", line 22, in run
starter.prepare()
File "/home/paul/plone_sites/plone/buildout-cache/eggs/Zope2-2.13.27-py2.7.egg/Zope2/Startup/init.py", line 92, in prepare
self.startZope()
File "/home/paul/plone_sites/plone/buildout-cache/eggs/Zope2-2.13.27-py2.7.egg/Zope2/Startup/init.py", line 268, in startZope
Zope2.startup()
File "/home/paul/plone_sites/plone/buildout-cache/eggs/Zope2-2.13.27-py2.7.egg/Zope2/init.py", line 47, in startup
_startup()
File "/home/paul/plone_sites/plone/buildout-cache/eggs/Zope2-2.13.27-py2.7.egg/Zope2/App/startup.py", line 120, in startup
load_zcml()
File "/home/paul/plone_sites/plone/buildout-cache/eggs/Zope2-2.13.27-py2.7.egg/Zope2/App/startup.py", line 52, in load_zcml
load_site()
File "/home/paul/plone_sites/plone/buildout-cache/eggs/Zope2-2.13.27-py2.7.egg/Zope2/App/zcml.py", line 46, in load_site
_context = xmlconfig.file(site_zcml)
File "/home/paul/plone_sites/plone/buildout-cache/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/xmlconfig.py", line 651, in file
context.execute_actions()
File "/home/paul/plone_sites/plone/buildout-cache/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/config.py", line 626, in execute_actions
callable(*args, **kw)
File "/home/paul/plone_sites/plone/buildout-cache/eggs/AccessControl-3.0.14-py2.7-linux-x86_64.egg/AccessControl/security.py", line 165, in protectClass
permission = getUtility(IPermission, name=permission_id)
File "/home/paul/plone_sites/plone/buildout-cache/eggs/zope.component-4.4.1-py2.7.egg/zope/component/_api.py", line 169, in getUtility
raise ComponentLookupError(interface, name)
zope.configuration.config.ConfigurationExecutionError: <class 'zope.interface.interfaces.ComponentLookupError'>: (, 'cmf.ManagePortal')
in:
File "/home/paul/plone_sites/plone/buildout-cache/eggs/medialog.imageexport-0.5-py2.7.egg/medialog/imageexport/browser/configure.zcml", line 7.7-12.9
<browser:page
name="image-export"
for="Products.CMFCore.interfaces._content.IFolderish"
class=".imageexport.Exporter"
permission="cmf.ManagePortal"
/>

I will try to look at it tomorrow, you could try to add this to the configure.zcml file.

<include package="Products.CMFCore" file="permissions.zcml" />

Thank you so much for your effort.
I added the line to configure.zcml file after running the buildout. It now works perfectly for folders with images.
That saves me so much time ....

I just tested it on Plone 5.2 / Python 3.

I did not need the 'extra line', but the zipping part has changed from Python 2 to 3, so it line 100 in imageexport.py needs to be changed to 'whatever the syntax for this is in python 3.

Can you check if it (still) works with collections ?
(collections changed from 4 to 5, so I am not sure if it does)

https://stackoverflow.com/questions/32131230/python-file-function

file -> open

$ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> file = open
>>> file('/tmp/test.txt').read()
'test\n'
>>> 
$ python2.7
Python 2.7.16 (default, Oct 10 2019, 22:02:15) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> file = open
>>> file('/tmp/test.txt').read()
'test\n'
>>>

So assigning open to file works both in python2 and python3.

This is an older instance runing under Plone-5.1.5 and Python 2.7.15 and was originally installed with the UnifiedInstaller under Linux.
I had to make the change to the configure.zcml file, without this change I get the error described above.
I made a test collection.
Unfortunately the export does not work for collections.
I get the error message "Site does not exist".

It gives me unicode error on python3. I will look into it if anyone is using this add-on

Sorry, I tested it with plain strings. I this sys.version_info is better to check the python version. Maybe the file must be opened in binary in python3?

>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
>>> sys.version_info[0]
3
>>> 
$ python2.7
>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=16, releaselevel='final', serial=0)
>>> sys.version_info[0]
2
>>>

Yes, that works ( but gives an error about file length when writing the zip, the header length is wrong / not same as file length )

Yes I'm also having the same issue.
I would like to upgrade our 4.3 site to v6, but when I upload a test folder of html files pngs jpgs and pdfs via webdav the images show zero size and the html files have header info mixed in at the top.

I have added webdav directives to my buildout.cfg shown below to enable webdav and got no errors after venv/bin/buildout.

In 4.3 I used a product called Marshaller Registry and set it to "Primary Field" to make things behave. Text was processed, and binary files were sent to blob storage, and images had their previews created. Is there a way the primary field behavior can be set for the new type objects in Plone 5/6? For me WebDav upload/download was a fundamental selling point of Plone.

www radiance-online org/community/plone-tips

I also would like to migrate html and rst content off another site onto a shiny new Plone6 site :slight_smile:

Here is the complete contents of my buildout.cfg :slight_smile:

[buildout]
extends =
    https://dist.plone.org/release/6-latest/versions.cfg

parts =
    instance

[instance]
recipe = plone.recipe.zope2instance

# user = username:password - Use a secure token in a production environment.
user = admin:admin

http-address = 127.0.0.1:9090 127.0.0.1:8080
http-fast-listen = true
zope-conf-additional =
    webdav-source-port 9090
    http-realm Welcome at Zeoclient1

eggs =
    Plone

Just to be sure: You are talking about 'adding images to Plone' (not exporting them):
Also just to be sure: Your webdav client uses port 9090 (I 'kind of remember' that using the wrong port gave 'empty images'.

Off topic: It is (now) possible to batch upload files/images by going to /folder_contents of a folder, that could be a workaround (?) since it is 'just as easy'

Yes adding content via webdav 9090 is when I encounter issues.

When I add images and text through the web (TTW):

  • TTW everything mostly looks fine

  • When downloaded via webdav:9090
    all content is prepended with rfc822 header information
    (which is expected after reading the docs since it uses
    rfc2882 through webdav by default)

When I upload folders of images, files(pdfs) and text via webdav:9090:

  • images & files : throw (500 Internal Server Error) (using Transmit on the mac)
    or register with zero kb (using mac finder)

  • text : accepts html / rst content but the pages show up as unrendered
    and need to be 'edited' and 'saved' (with no changes) TTW for them to
    be rendered properly

  • folders cannot be deleted (405 method not allowed) via Transmit or Finder
    I'm guessing because of the immovable Dexterity _data files.

For now I just want to change the marshalling behavior of webdav from rfc822 to 'primary field'
ie to suppress the header information showing in the body of the file.

The developer docs mention something about customizing IRawFile or something like
that to alter the behavior but I don't have a good example to go by to make the change.

It seems like there should be a setting somewhere to change the webdav behavior
like the old AT based MarshallerRegisty product does.

By the way I tried navigating to '/folder_contents' within a folder using the
'Go to Folder' function on both Transmit and mac Finder but was unsuccessful.

On the other hand Plone has gotten a lot easier to stand-up via buildout, and the
TTW has gotten a lot slicker! Good job!

I just realized by '/folder_contents' you meant TTW

  • that worked with the images and files :slight_smile:
  • interestingly now the text files (html / rst) only registered with header info - no body info
  • folder hierarchy got flattened.

Thanks for your responses and suggestions though - much appreciated!

TTW upload of text documents (html / txt / rst) issues mentioned here by the way - as far as I know not yet resolved.

https://community.plone.org/t/bug-upload-text-file-to-folder-nothing-there-plone-5-1-rc-2/5609

There are clues to the solution here:

https://5.docs.plone.org/external/plone.app.dexterity/docs/advanced/webdav-and-other-file-representations.html

But I'm not literate with Plone development!

I have a vague memory: it might be possible to import html (etc) by defining '.html' as 'Document or Page' in mimetype registry or similar if using webdav. In /folder_contents upload they might end up as 'files'. What happens if you try to edit them?

Yeah I tried futzing with both
http://localhost:8080/Plone/content_type_registry/manage_predicates
http://localhost:8080/Plone/mimetypes_registry/manage_main

I'm looking here for more clues
plone.dexterity/docs/WebDAV.txt at master · plone/plone.dexterity · GitHub
GitHub - plone/plone.app.contenttypes: Dexterity-based content types for Plone

Images + Files work when uploaded TTW

Folders and text Documents work when uploaded WebDAV

So the functions exist ; it might be a matter of overriding some files as mentioned from the WebDAV documentation.