MediaFire encode filename in url, only report upload progress

This commit is contained in:
Jaex 2014-07-23 04:48:11 +03:00
parent 8818c57e87
commit 6358e1d0bd

View file

@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License
// Credits: https://github.com/michalx2
using HelpersLib;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@ -57,8 +58,11 @@ public MediaFire(string appId, string apiKey, string user, string pasw, string p
public override UploadResult Upload(Stream stream, string fileName)
{
AllowReportProgress = false;
GetSessionToken();
AllowReportProgress = true;
string key = SimpleUpload(stream, fileName);
AllowReportProgress = false;
string url = null;
while ((url = PollUpload(key, fileName)) == null) Thread.Sleep(_pollInterval);
return new UploadResult() { IsSuccess = true, URL = url };
@ -118,7 +122,7 @@ private string PollUpload(string uploadKey, string fileName)
if (resp.doupload.status == 99)
{
if (resp.doupload.quickkey == null) throw new IOException("Invalid response");
return string.Format("http://www.mediafire.com/view/{0}/{1}", resp.doupload.quickkey, resp.doupload.filename);
return string.Format("http://www.mediafire.com/view/{0}/{1}", resp.doupload.quickkey, URLHelpers.URLEncode(resp.doupload.filename));
}
return null;
}