Private Sub Button1_Click
Dim base As String = Base64EncodeDecodeImage.Base64ImageToString(File.DirAssets,"test.jpg")
Dim hj As HttpJob
hj.Initialize("hj",Me)
Dim sb As StringBuilder
sb.Initialize
sb.Append($""key=MY_KEY&image="$).Append(base).Append($"""$)
Log(sb.ToString)
hj.PostString("https://api.imgbb.com/1/upload",sb.ToString)
wait for (hj) JobDone(hj As HttpJob)
Log(hj.GetString)
End Sub
If I execute the code as above, an error will occur.
ResponseError. Reason: , Response: {"status_code":400,"error":{"message":"Invalid API v1 key.","code":100,"context":"Exception"},"status_txt":"Bad Request"}
1. The key should be sent in the URL (GET parameter).
2. The request should be sent with Job.PustMultipart where the image key and value are in the NameValues map.
Private Sub Button1_Click
Dim b64 As Base64Convert
b64.Initialize
Dim base As String = b64.EncodeFromImage(File.DirAssets,"test.jpg")
ImageView1.Bitmap = b64.DecodeToImage(base)
Dim j As HttpJob
j.Initialize("",Me)
Dim m As Map
m.Initialize
m.Put("key","39ec6479229e77e4dfe96b3135c2???")
m.Put("image",base)
j.PostMultipart("https://api.imgbb.com/1/upload",m,Null)
wait for (j) JobDone(j As HttpJob)
Log(j.GetString)
j.Release
End Sub
But there's been no response this time.
Do I also need to use file parameters?
And the base64 conversion library used in the first post was not working properly, so I changed it to another library.
Private Sub Button1_Click
Dim b64 As Base64Convert
b64.Initialize
Dim base As String = b64.EncodeFromImage(File.DirAssets,"test.jpg")
ImageView1.Bitmap = b64.DecodeToImage(base)
Dim m As Map
m.Initialize
m.Put("image",base)
Dim j As HttpJob
j.Initialize("",Me)
j.PostMultipart("https://api.imgbb.com/1/upload?key=YOUR-KEY",m,Null)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
End Sub