Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP Media Plugin version 1.3, UUID filenames

Is anybody else using David Persson's media plugin for CakePHP? I'm struggling with setting up some features of the latest version. I'd like to set it up to make a UUID-based filename for uploaded images, but I'm not sure how to go about it.

I will fight with it some more, but I'm posting to find out if anybody here can tell me if the 1.3 is generally working or generally NOT working.

like image 298
Randy L Avatar asked Nov 06 '22 11:11

Randy L


1 Answers

Finally got this (partially) working. The UUID filename stuff works when I place the following code in my Attachment model:

function transferTo($via, $from) {
    extract($from);
    $irregular = array(
        'image' => 'img',
        'text' => 'txt'
    );
    $name = Mime_Type::guessName($mimeType ? $mimeType : $file);
    if (isset($irregular[$name])) {
        $short = $irregular[$name];
    } else {
        $short = substr($name, 0, 3);
    }
    $path  = $short . DS;
    $path .= String::uuid();
    $path .= !empty($extension) ? '.' . strtolower($extension) : null;
    return $path;
}

I'm still having some trouble with other parts of the Media Helper, but the author posted some updates to his git repository today (Jul 17 2010).

like image 171
Randy L Avatar answered Nov 12 '22 22:11

Randy L