DevFactoryCH / media

Laravel 4/5 package that saves uploaded files and links them with the associated model
MIT License
17 stars 5 forks source link

Suggestion for new renaming method #7

Open alexglue opened 9 years ago

alexglue commented 9 years ago

Could u please to add simple md5() renaming without part of original name? And it will be nice to store files to subdirectories in this case, like /public/de/ad/be/ef/12/bb/ce/ed/deadbeef12bbceed.jpg for example.

alexglue commented 8 years ago
  private function getFilename() {
    switch (config('media.config.rename')) {
      case 'transliterate':
        $this->filename_new = \Transliteration::clean_filename($this->filename_original);
        break;
      case 'unique':
        $this->filename_new = md5(microtime() . str_random(5)) .'.'. $this->filename_original;
        break;
      case 'nothing':
        $this->filename_new = $this->file->getClientOriginalName();
        break;
    }

    return $this->fileExistsRename();
  }

This is bad code. And I can do nothing to overload it, cause it's private.
I can do nothig to extend filename generation with my own function, md5() etc.
markcameron commented 8 years ago

You could make a pull request..