Upload files using a parallel web worker.

This module provides a web worker and server logic to quickly upload files.

The web worker sends files in 128KB parts to the server, the server recombines all parts to a single file. The web worker is using multiple parallel uploaders to make optimal use of the available bandwidth.

Files are sent to the webworker on the topic model/fileuploader/post/new:

let f = document.getElementById("upload_file").files[0];

let msg = {
    files: [
            name: "resultname",             // The name used in the ready message
            upload: "WZkhXoaMwrK2StUHmdpp", // Unique name to register the upload process. It's generated by the server if undefined
            file: f                         // Must be a File object

    start_topic: "bridge/origin/foo", // Receives the upload metadata when the upload starts

    ready_msg: {
        foo: "bar",                 // Anything you want to send if all files are uploaded
        files: []                   // This will be set by the worker
    ready_topic: "bridge/origin/foo/bar",

    progress_msg: {
        form_id: "some-element-id",
        is_auto_unmask: true,
        percentage: 0               // Will be set by the uploader, 100 when ready
    progress_topic: "zotonic-transport/progress"
};"model/fileuploader/post/new", msg);

The files received with the ready_msg on the ready_topic will be:

    name: "resultname",             // Name provided in the upload
    upload: "WZkhXoaMwrK2StUHmdpp"  // Unique name to use with z_fileuploader:status/1

An upload can be canceled by publishing the topic model/fileuploader/post/delete/+name, where the name is the unique name generated by the server.

Edit on GitHub



Model to start uploads, upload a block and delete uploads.



The fileuploader controller is used to upload parts of a file.

Dispatch rules


Dispatch rules Name Path Resource Args fileuploader [“fileuploader”,”upload”,name] controller_fileuploader []…

Referred by

All dispatch rules

All the dispatch rules from all modules. For a background on dispatch rules, see The URL dispatch system.