Skip to content

Instantly share code, notes, and snippets.

@rankun203
Created February 13, 2016 10:36
Show Gist options
  • Save rankun203/a378c6a5cf11112f31af to your computer and use it in GitHub Desktop.
Save rankun203/a378c6a5cf11112f31af to your computer and use it in GitHub Desktop.
function genFileKey()
/**
* 根据文件名生成文件的 key
* @param fileName
* @returns {string}
*/
function genFileKey(fileName) {
var fileKey = '';
// 将文件名中的有效字符提取出来作为文件 key
var realFileName = fileName.match(/[\w|\.]/g).join('');
if (realFileName.startsWith('.')) realFileName = '_' + realFileName;
if (thisUser) fileKey += thisUser.id + '/';
fileKey += Functions.guid() + '/' + realFileName;
return fileKey;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment