Add ability to change the extension of downloaded files (#5017)

Add ability to change the extension of downloaded files

Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert 2019-06-15 16:39:30 +09:00 committed by GitHub
commit 410d0b4ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,9 +10,18 @@ namespace osu.Game.Online.API
{
private string filename;
/// <summary>
/// Used to set the extension of the file returned by this request.
/// </summary>
protected virtual string FileExtension { get; } = @".tmp";
protected override WebRequest CreateWebRequest()
{
var request = new FileWebRequest(filename = Path.GetTempFileName(), Uri);
var file = Path.GetTempFileName();
File.Move(file, filename = Path.ChangeExtension(file, FileExtension));
var request = new FileWebRequest(filename, Uri);
request.DownloadProgress += request_Progress;
return request;
}