cancel
Showing results for 
Search instead for 
Did you mean: 

Download workspace as zip

mcruz
Champ in-the-making
Champ in-the-making
Hi !

I'm working with Alfresco Labs 3 Stable. I would like to know to download a workspace (with all its documents and subworkspaces) in zip format.

I know I can use the export option, but the file it creates (acp) doesn't respect the structure you have in your repository. I mean, if you open it, you can't see the subworkspaces and documents structure you have in Alfresco (even the file names are changed)

Is there any way to download the workspace as a zip file (or any other format) so you have the same view of the content once you unzip it?

Thank you very much
8 REPLIES 8

paulhh
Champ in-the-making
Champ in-the-making
Yes - access the repository via CIFS and use your favourite zip program 🙂

Paul.

mcruz
Champ in-the-making
Champ in-the-making
Thanks for your reply paulh,

That's a bit confusing for people who are used to working with Alfresco web interface, isn't it? I mean, they can do everything from there, so they won't like having to change to "another view" to get some documentation they can send to other people  Smiley Happy

mcruz
Champ in-the-making
Champ in-the-making
Has anybody designed a solution for this common situation? (Work with Alfresco's web interface and download a workspace and its content)

Thank you very much

oneporter
Champ in-the-making
Champ in-the-making
I'm also working on this problem.  My first thoughts are to create a custom action that applies to folders and will create a zip of the folder on which the action is run..  Has anyone made any headway? 

Thanks

oneporter
Champ in-the-making
Champ in-the-making
I wrote a crude extractor for the acp format for our project.  It only finds cm:content and cm:folder nodes.  So, if you needed the contents of Data Dictionary for example, I think you would miss some files..  Anyway, if you can't use it, maybe someone else will be able to.


# acpParser.py
# Requires Windows, Python 3.0+, & lxml

from lxml import etree
import os,zipfile,sys

def extractFolderAndContent(source_node):
  for node in source_node:
    # If the node is a cm:folder node
    if (node.tag.find('{http://www.alfresco.org/model/content/1.0}folder') != -1):
        # print(node.tag)
        FOUND_PROPS = False
        for y in node:
            if (y.tag.find('{http://www.alfresco.org/view/repository/1.0}properties')):
                for x in node[2]:
                # Find the folder name node and save the name
                    if (x.tag.find('name') != -1):
                        # print('Folder: ',x.text)
                        folderName = x.text
                        FOUND_PROPS = True
                        break
            if (FOUND_PROPS == True):
                break
      # Make the Folder
        os.mkdir(folderName)
      # print('CD: ', folderName)
      # Move into the Folder
        os.chdir(folderName)
      # print('MID: ',folderName)
      # Find the view:associations tag and save it in
        for x in node:
            if (x.tag.find('{http://www.alfresco.org/view/repository/1.0}associations') != -1):
                try:
       #             print('Recursing with',x[0],sep=' ')
                    extractFolderAndContent(x[0])  #   Pass in the cm:contains node
                except:
                    print('Empty folder')
                break
      # Move out of the Folder
        os.chdir(os.pardir)
    elif (node.tag.find('{http://www.alfresco.org/model/content/1.0}content') != -1):
        print('FOUND CONTENT NODE ',node.tag)
        for y in node:
#            print(y.tag)
            if y.tag.find('{http://www.alfresco.org/view/repository/1.0}properties') != -1:
                for x in y:
                    if (x.tag.find('{http://www.alfresco.org/model/content/1.0}name') != -1):
                        print(x.text)
                        realName = x.text
                    if (x.tag.find('{http://www.alfresco.org/model/content/1.0}content') != -1):
                        print(x.text)
                        alfName = x.text.split('|')[0].split('=')[1]
                        break
                break
        alfZipName = alfName.replace('\\','/')
        theZip.extract(alfZipName)
      #  print('EF: ',alfZipName)
        os.rename(alfName, realName)
      #  print('MF:',alfName,'///',realName,sep=' ')
        try:
            os.rmdir(name)
#            print('RD:',name,sep=' ')
        except:
            print('Tried to delete non-existant folder.  Continuing')

zipName = sys.argv[1]
absZip = os.path.abspath('.') + '\\' + zipName
theZip = zipfile.ZipFile(absZip)
name = zipName.split('.')[0]
manifest = name + '.xml'
theZip.extract(manifest)
manifest = os.path.abspath('.') + '\\' + manifest
dom = etree.parse(manifest)
root = dom.getroot()

extractFolderAndContent(root)
os.remove(manifest)

t_n_a_
Champ in-the-making
Champ in-the-making
Yes - access the repository via CIFS and use your favourite zip program 🙂
Paul.

While we get a lot of value from it as it is, our instance of Alfresco doesn't have CIFS running (correctly), so we do not have that option at all. I event tried a couple of generic WebDAV clients one of which explicitly declares recursive copy capabilities, but it wasn't even able to connect. It really is surprising that there is no other way to copy a directory hierarchy from alfresco to a local filesystem other than CIFS… Smiley Indifferent

mrogers
Star Contributor
Star Contributor
There's two approaches.   You can either package up your content on the server and then download that bundle in the same way that export via ACP works.    Or you can use one of the file system projections to select the files you want and do the packaging on your client.

And of course there are other protocols that alfresco supports, the best choices probably being ftp or cmis.

lawsonphoto99
Champ in-the-making
Champ in-the-making
There's two approaches. You can either package up your content on the server and then download that bundle in the same way that export via ACP works. Or you can use one of the file system projections to select the files you want and do the packaging on your client.

I prefer the first approach, packaging up your content on the server has yielded better results for me in the past – the only way to go!