Skip to content
This repository was archived by the owner on Feb 3, 2019. It is now read-only.

Commit 48bc23b

Browse files
author
Mike
committed
Upload 403 fix
1 parent cd93199 commit 48bc23b

2 files changed

Lines changed: 412 additions & 412 deletions

File tree

cls_Imgur.cs

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Collections.Specialized;
4-
using System.Drawing;
5-
using System.Net;
6-
using System.Text;
7-
8-
namespace hyperdesktop2
9-
{
10-
class Imgur
11-
{
12-
public static WebClient web_client = new WebClient();
13-
14-
public static Boolean upload(Bitmap bmp)
15-
{
16-
try
17-
{
18-
var data = new NameValueCollection();
19-
20-
var image = Global_Func.bmp_to_base64(bmp, Global_Func.ext_to_imageformat(Settings.upload_format));
21-
data.Add("image", image);
22-
23-
web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
24-
web_client.UploadValuesAsync(
25-
new Uri("https://api.imgur.com/3/image/"),
26-
"POST",
27-
data
28-
);
29-
30-
web_client.Dispose();
31-
}
32-
catch
33-
{
34-
return false;
35-
}
36-
37-
return true;
38-
}
39-
40-
public static Boolean delete(String delete_hash)
41-
{
42-
try
43-
{
44-
var web_client = new WebClient();
45-
46-
web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
47-
web_client.UploadData(
48-
new Uri("https://api.imgur.com/3/image/" + delete_hash),
49-
"DELETE",
50-
new Byte[] { 0x0 }
51-
);
52-
53-
web_client.Dispose();
54-
return true;
55-
}
56-
catch
57-
{
58-
return false;
59-
}
60-
}
61-
}
62-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.Specialized;
4+
using System.Drawing;
5+
using System.Net;
6+
using System.Text;
7+
8+
namespace hyperdesktop2
9+
{
10+
class Imgur
11+
{
12+
public static WebClient web_client = new WebClient();
13+
14+
public static Boolean upload(Bitmap bmp)
15+
{
16+
try
17+
{
18+
var data = new NameValueCollection();
19+
20+
var image = Global_Func.bmp_to_base64(bmp, Global_Func.ext_to_imageformat(Settings.upload_format));
21+
data.Add("image", image);
22+
23+
web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
24+
web_client.UploadValuesAsync(
25+
new Uri("https://api.imgur.com/3/image/"),
26+
"POST",
27+
data
28+
);
29+
30+
web_client.Headers.Remove("Authorization");
31+
}
32+
catch
33+
{
34+
return false;
35+
}
36+
37+
return true;
38+
}
39+
40+
public static Boolean delete(String delete_hash)
41+
{
42+
try
43+
{
44+
var web_client = new WebClient();
45+
46+
web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
47+
web_client.UploadData(
48+
new Uri("https://api.imgur.com/3/image/" + delete_hash),
49+
"DELETE",
50+
new Byte[] { 0x0 }
51+
);
52+
53+
web_client.Dispose();
54+
return true;
55+
}
56+
catch
57+
{
58+
return false;
59+
}
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)