Last active
May 10, 2019 18:15
-
-
Save ceelsoin/22d41f402539cb9dd3051f6f801ed546 to your computer and use it in GitHub Desktop.
C# multipart/form-data upload
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
public static async Task sendScreenShotResult(string fullPath, string game_code) | |
{ | |
LogHandler _LogHandler = new LogHandler(); | |
try | |
{ | |
var url = Config.HOST + "/api/battle/sendScreenShotResult/" + game_code; | |
string filename = Path.GetFileName(fullPath); | |
string CT = "image/jpeg"; | |
FormUpload.FileParameter f = new FormUpload.FileParameter(File.ReadAllBytes(fullPath), filename, "multipart/form-data"); | |
Dictionary<string, object> d = new Dictionary<string, object>(); | |
d.Add("file", f); | |
string ua = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2"; | |
FormUpload.MultipartFormDataPost(url, ua, d); | |
_LogHandler.SendLog("EVENT_LOBBY", "Screenshots enviados."); | |
} | |
catch(Exception ex) | |
{ | |
_LogHandler.SendLog("HTTP_ERROR", "Falha ao enviar screenshots: " + ex); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment