Fixed for Imgur annonymous upload.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2177 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-10-20 13:41:59 +00:00
commit 428b84ac6d
2 changed files with 17 additions and 13 deletions

View file

@ -4,7 +4,7 @@ Greenshot: A screenshot tool optimized for productivity. Save a screenshot or a
CHANGE LOG:
We changed the version to 1.0 after 5 years it should no longer have a "beta" feeling!
1.0.4 build 2176 Release Candidate 4
1.0.4 build 2177 Release Candidate 4
Bugs resolved:
* Fixed error during OAuth process due to authorization dialog not opening, see bug #3578480

View file

@ -112,22 +112,26 @@ namespace GreenshotImgurPlugin {
}
string responseString = null;
if (config.AnonymousAccess) {
// add key
uploadParameters.Add("key", IMGUR_ANONYMOUS_API_KEY);
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(config.ImgurApiUrl + "/upload.xml?" + NetworkHelper.GenerateQueryParameters(uploadParameters) + NetworkHelper.GenerateQueryParameters(otherParameters));
// add key, we only use the other parameters for the AnonymousAccess
otherParameters.Add("key", IMGUR_ANONYMOUS_API_KEY);
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(config.ImgurApiUrl + "/upload.xml?" + NetworkHelper.GenerateQueryParameters(otherParameters));
webRequest.Method = "POST";
webRequest.ContentType = "image/" + outputSettings.Format.ToString();
webRequest.ServicePoint.Expect100Continue = false;
using (var requestStream = webRequest.GetRequestStream()) {
ImageOutput.SaveToStream(image, requestStream, outputSettings);
}
responseString = NetworkHelper.GetResponse(webRequest);
using (WebResponse response = webRequest.GetResponse()) {
LogCredits(response);
using (StreamReader reader = new StreamReader(response.GetResponseStream(), true)) {
responseString = reader.ReadToEnd();
try {
using (var requestStream = webRequest.GetRequestStream()) {
ImageOutput.SaveToStream(image, requestStream, outputSettings);
}
using (WebResponse response = webRequest.GetResponse()) {
using (StreamReader reader = new StreamReader(response.GetResponseStream(), true)) {
responseString = reader.ReadToEnd();
}
LogCredits(response);
}
} catch (Exception ex) {
LOG.Error("Upload to imgur gave an exeption: ", ex);
throw ex;
}
} else {
OAuthSession oAuth = new OAuthSession(ImgurCredentials.CONSUMER_KEY, ImgurCredentials.CONSUMER_SECRET);