Use internal upload method

This commit is contained in:
Jaex 2015-12-14 14:07:17 +02:00
parent 6e9c4ebcd3
commit 223d6938ba
2 changed files with 6 additions and 6 deletions

View file

@ -60,12 +60,9 @@ public sealed class Imgur : ImageUploader, IOAuth2
public bool DirectLink { get; set; }
public bool UseGIFV { get; set; }
private bool refreshTokenOnError;
public Imgur(OAuth2Info oauth)
{
AuthInfo = oauth;
refreshTokenOnError = true;
}
public string GetAuthorizationURL()
@ -181,6 +178,11 @@ public List<ImgurAlbumData> GetAlbums()
}
public override UploadResult Upload(Stream stream, string fileName)
{
return InternalUpload(stream, fileName, true);
}
private UploadResult InternalUpload(Stream stream, string fileName, bool refreshTokenOnError)
{
Dictionary<string, string> args = new Dictionary<string, string>();
NameValueCollection headers;
@ -274,8 +276,7 @@ public override UploadResult Upload(Stream stream, string fileName)
{
DebugHelper.WriteLine("Imgur access token refreshed, reuploading image.");
refreshTokenOnError = false;
return Upload(stream, fileName);
return InternalUpload(stream, fileName, false);
}
string errorMessage = string.Format("Imgur upload failed: ({0}) {1}", imgurResponse.status, errorData.error);

View file

@ -66,7 +66,6 @@ public AboutForm()
Mega, Gist and Jira support: https://github.com/gpailler
Web site: https://github.com/dmxt
MediaCrush (Imgrush) support: https://github.com/SirCmpwn
Amazon S3 and DreamObjects support: https://github.com/alanedwardes
Gfycat support: https://github.com/Dinnerbone
Copy support: https://github.com/KamilKZ