Re: Cake Media Plugin: How to create dynamic directories
Great!!! Thanks Jeremy. James On Thursday, April 19, 2012 6:35:28 PM UTC-4, jeremyharris wrote: > > Yes, as defined in the transferTo function in your model. Here's a sample > one that sticks it under a user directory and uses a UUID as the filename > so there aren't conflicts (so something like > /media/transfer/doc/user/550e8400-e29b-41d4-a716-44665544.doc): > > function transferTo($via, $from) { > extract($from); > > $irregular = array( > 'image' => 'img', > 'text' => 'txt' > ); > $name = Mime_Type::guessName($mimeType ? $mimeType : $file); > if (empty($extension)) { > $extension = Mime_Type::guessExtension($mimeType ? $mimeType : $file); > } > > if (isset($irregular[$name])) { > $short = $irregular[$name]; > } else { > $short = substr($name, 0, 3); > } > > $path = $short . DS; > $path .= 'user' . DS; // make this as dynamic as you want > $path .= String::uuid(); // uses a uuid as the doc name instead > $path .= !empty($extension) ? '.' . strtolower($extension) : null; > > return $path; > } > > This is defined on the model that $actsAs Media.Transfer. > > On Thursday, April 19, 2012 8:49:00 AM UTC-7, James Dcunha wrote: >> >> Hello all, >> >> With cake media plugin can we configure the plugin to create dynamic >> subdirectories dynamically inside the transfer folder without changing the >> plugin core code. >> >> Example with default settings I can transfer document files to >> WWW_ROOT/media/transfer/doc/test.doc >> >> Could we configure it to transfer document files >> to WWW_ROOT/media/transfer/doc/*{subdirectory}*/test.doc >> >> Regards >> James >> > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Cake Media Plugin: How to create dynamic directories
Hello all, With cake media plugin can we configure the plugin to create dynamic subdirectories dynamically inside the transfer folder without changing the plugin core code. Example with default settings I can transfer document files to WWW_ROOT/media/transfer/doc/test.doc Could we configure it to transfer document files to WWW_ROOT/media/transfer/doc/*{subdirectory}*/test.doc Regards James -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Cake Media Plugin: How to enable .docx files for upload and retrieve errors if upload fails
Hello all, I am using CakePHP 1.3 and Cake Media plugin (https://github.com/davidpersson/media). With the default setting I am able to upload images and pdf. I tried to upload a .docx file and I am not able to upload it. Following is the validate rule in my Document model > > class Document extends AppModel { > > var $name = 'Document'; > > >> //media plugin behaviors > > var $actsAs = array( > > 'Media.Transfer', > > 'Media.Coupler', > > 'Media.Generator' > > ); > > >> var $validate = array( >> > 'file' => array( > > 'mimeType' => array( > > 'rule' => array('checkMimeType', false, array ( >> 'text/plain','application/pdf', > > 'application/msword', > > 'application/rtf',' >> application/vnd.openxmlformats-officedocument.wordprocessingml.document')) > > ), > > 'size' => array( > > 'rule' => array('checkSize' , '120M') > > ) > > )); > > > > } > > > I tried adding the "extension" values in my validate array but it did not work either. Let me know if I am missing something. Another question how do I retrieve the errors for failing to upload from the media plugin in my controller. Would $errors = $this->Document->invalidFields(); work? Regards James > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php