Created
May 15, 2015 12:50
-
-
Save BartDM/3ac21802a09f0ce93049 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Specialized; | |
using System.Net; | |
using Greenshot.IniFile; | |
using GreenshotPlugin.Core; | |
namespace GreenshotDemoPlugin | |
{ | |
public class DemoConnector: IDisposable | |
{ | |
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DemoConnector)); | |
private static DemoConfiguration config = IniConfig.GetIniSection<DemoConfiguration>(); | |
private string url; | |
public void Dispose() | |
{ | |
GC.SuppressFinalize(this); | |
} | |
public DemoConnector() | |
{ | |
this.url = config.Url; | |
} | |
public void AddAttachment(string fileName, IBinaryContainer attachment) | |
{ | |
var file = attachment.ToBase64String(Base64FormattingOptions.InsertLineBreaks); | |
LOG.DebugFormat("adding image {0}", file); | |
using (var client = new WebClient()) | |
{ | |
client.UploadValues(url, | |
new NameValueCollection() | |
{ | |
{"imageBase64String",file}, | |
{"fileName",fileName}, | |
{"ticketNr","Test ticket"} | |
}); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment