Bulk Operations Downloads

I have a client that has a music upload/download site and I've set it up as a custom PHP site.

I want to see about bringing it into Drupal, but I need to be able to have the producer upload bulk tracks to sample and then have artists be able to download multiple files at once.

I think there are a few different bulk uploading modules out there which will hopefully be easy to implement. I was thinking about using Views Bulk Operations to handle the file downloading, but I haven't done any work at all with VBO or actions and I am still pretty new to views. I read a little on batch processing and was wondering if a good way to do this would be to have my action that VBO fires off be a function to add that node to the the batch to get processed and at the end have another function do the processing which would involve zipping up the folders and downloading them.

Is this the best way or does anyone else have any ideas on what else could be done?

Thank you,

James

Login to post comments

Hi James -- There's a fairly

axolx's picture
axolx - Mon, 2009-11-02 03:08

Hi James --

There's a fairly simple way to do that if your bulk operations view (BOV) is a node view where each node is one of the files the user may want to download. You define a node operation by implementing hook_node_oprations like this:

function mymodule_node_operations()
{
    $operations = array(
        'download' => array(
            'label' => 'My Download Operation',
            'callback' => 'mymodule_download_function',
        ),
    );
    return $operations;
}

Then you set the operation for the BOV to "My Download Operation", and the view will call mymodule_download_function (the callback) passing it an array of the selected NIDs argument. The next steps depend on your requirements. For example, you could have mymodule_download_function iterate over the NIDs, grab the files, zip them and send them as an inline attachment in the HTTP response.

Hope that helps.

Best,
Martin