开发者

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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜