Skip to content

Commit

Permalink
fix: get file MD5 from netease URL
Browse files Browse the repository at this point in the history
Netease now has different formats of URL,
hard-coding an index won't work.
  • Loading branch information
y-young committed Mar 19, 2023
1 parent 8bcd83b commit d69c358
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Http/Controllers/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ private static function getFileFromRequest(Request $request)
if (empty($url)) {
throw new \Exception('暂不支持无版权或付费歌曲,请手动上传');
}
$file->name = explode('/', $url)[9];
$file->md5 = substr($file->name, 0, -4);
$pathInfo = pathinfo($url);
$file->name = $pathInfo['basename'];
$file->md5 = $pathInfo['filename'];
Storage::disk('tmp')->put($file->name, file_get_contents($url));
$file->url = $tmpDir . $file->name;
}
Expand Down Expand Up @@ -276,4 +277,4 @@ class UnvalidatedFile
public $songOrigin = null;
public $url = null;
public $cloudId = null;
}
}

0 comments on commit d69c358

Please sign in to comment.