コード例 #1
0
ファイル: AppForm.cs プロジェクト: RiceCX/CUPID
        private async void uploadImageAsync(Bitmap target)
        {
            Console.WriteLine("uploading SCREENSHOT");
            //  WebClient webClient = new WebClient();
            HttpClient  client        = new HttpClient();
            HttpContent bytesContent  = new ByteArrayContent(ImageToByte(target));
            HttpContent stringContent = new StringContent(config.Uploadconfiguration.Arguments.token);
            var         formData      = new MultipartFormDataContent();

            client.DefaultRequestHeaders.Add("User-Agent", "CUPID/V1.0");
            if (config.Uploadconfiguration.Arguments.token.Length != 0)
            {
                formData.Add(stringContent, "token");
            }
            formData.Add(bytesContent, "image", "image");
            try {
                var response = await client.PostAsync(config.Uploadconfiguration.RequestURL, formData);

                if (!response.IsSuccessStatusCode)
                {
                    return;
                }
                var data = await response.Content.ReadAsByteArrayAsync();

                var f**k = ServerResponse.parse(data);
                var lv   = new UploadBox {
                    Link = f**k, dbc = db
                };
                lv.Show();
                db.updateTables(f**k.url, f**k.del_url, f**k.thumb);
            } catch (HttpRequestException e) {
                MessageBox.Show("ERROR: " + e.Message);
            }
        }
コード例 #2
0
 private void UploadBox_Load(object sender, EventArgs e)
 {
     FormBorderStyle = FormBorderStyle.FixedToolWindow;
     dbc.updateTables(Link.url, Link.del_url, Link.thumb);
     URLText.Text = Link.url;
     PlaceLowerRight();
     TopMost = true;
 }