My image host returns a link starting with http://
. It seems this format is not supported in SE anymore. To avoid this, I want to change the image host to Imgur. But I have failed to call it right.
There is a code write by Arnoud Buzing here:
Import["http://api.imgur.com/2/upload", "XML",
"RequestMethod" -> "POST",
"RequestParameters" -> {"key" -> apikey, "image" -> image}]
But it does not seem to work anymore.
And this code derived from halirutan
$file = Export["tmp/img.png", Plot[Sin[x], {x, 0, 2 Pi}], "PNG"];
$req = HTTPRequest[
"https://api.imgur.com/3/image", <|Method -> "Post",
"Headers" -> {"Authorization" -> "Client-ID 93d5e807261cc90",
"Accept" -> "application/json"},
"Body" -> {"image" -> File[$file], "type" -> "file"}|>];
URLRead[$req];
Import[%]
Actually I'm out of the firewall now and I can upload images using this button, but I get the following error information from halirutan's code:
{status->500,success->False,data->{error->Imgur is temporarily over capacity. Please try again later.}}
This is my Imgur API information for testing. If this question is solved, I will change it maybe.
Client_Name:mmascript
Client_ID:93d5e807261cc90
Client_Secret:04eacd2b7aeb76b551d9c33a02ddbac4a27f8aa4
success->True
in the json output. $\endgroup$File
object and leave"type"->"file"
. Or you could try encoding your data asbase64
which seems to be another acceptable form. $\endgroup$