Files

The Cloud CMS Bulk Import tool makes it easy to import content from a file system into a Cloud CMS content repository.

Let's imagine that you have some images sitting in an images directory. You wish to ingest these into Cloud CMS as part of an Image Library application.

The image directory might look like this:

images\
    chunio.jpg
    disney.jpg
    pavlov.jpg

These images are just files on disk. They could be any file type, really. Cloud CMS can ingest files of any format including popular desktop formats like Microsoft Office and Adobe PDF as well as audio and video formats.

We can import these images into Cloud CMS by using the cloudcms-packager module like this:

var walk = require("fs-walk");
var fs = require("fs");
var path = require("path");

// create a packager
var PackagerFactory = require("cloudcms-packager");
PackagerFactory.create(function(err, packager) {

    var imageCount = 0;
    walk.walkSync("./images", function(basedir, filename, stat) {

        var alias = "image-" + (imageCount++);
        var obj = {
            "title": filename,
            "_alias": alias
        };
        packager.addNode(obj);

        packager.addAttachment(alias, "default", path.join(basedir, filename));
    });

    // commit
    packager.package(function(err, archiveInfo) {
        console.log("Wrote archive: " + archiveInfo.filename);
    });
});

For a full example of this code in action, please see:

https://github.com/gitana/cloudcms-packager/tree/master/examples/files/image-library